How To Start/Stop SQL Server Through The Command Line
I recently ran into an issue with a client where I couldn’t login to their SQL Server. I was able to access the data files, but because SQL locks the data files while it’s running, I had to find a way to stop the service remotely. I also included the method for stopping and starting the services locally. Note: be sure to run the stop command on the sqlserveragent service first, since trying to stop mssqlserver while the agent is running will throw an error.
Locally
net stop sqlserveragent
net stop mssqlserver
net start mssqlserver net start sqlserveragent
Remotely
sc \[SERVER] stop sqlserveragent
sc \[SERVER] stop mssqlserver
sc \[SERVER] start mssqlserver
sc \[SERVER] start sqlserveragent
