Following commands can be used to start stop SQL Server service from command prompt.
Note: Run Command prompt as Administrator
Start SQL Server 2008
[sourcecode language=”plain”]net start mssqlserver[/sourcecode]
Stop SQL Server 2008
[sourcecode language=”plain”]net stop mssqlserver[/sourcecode]
Restart SQL Server 2008
[sourcecode language=”plain”]
net stop mssqlserver
net start mssqlserver
[/sourcecode]
Advanced Topics:
If you want to start/Stop a specific sql server instance replace mssqlserver with the name of the instance specific service[sourcecode language=”plain”]
net stop <<sqlserverservicename>>
net start <<sqlserverservicename>>
[/sourcecode]
For SQL Server Express the name would be MSSQL$SQLEXPRESS
[sourcecode language=”plain”]
net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS
[/sourcecode]
How to find the service name?
1. Open Services.msc (open Run (windowskey+r) then type services.msc and click on ok)
2. In the read through the services(or click S to find all services starting with s)
3. Select a SQL Server service and doubleclick on it(or rightcick-properties)
4. In the popup you will have service name
5. Note down the service name (This is the name of the service – Display name is used for readability)
Following are the few of SQL Server related service names:
Display Name | Service Name |
---|---|
SQL Server (MSSQLSERVER) | MSSQLSERVER |
SQL Server Agent (MSSQLSERVER) | SQLSERVERAGENT |
SQL Server Analysis Services (MSSQLSERVER) | MSSQLServerOLAPService |
SQL Server Browser | SQLBrowser |
SQL Server Integration Services 10.0 | MsDtsServer100 |
SQL Server Reporting Services (MSSQLSERVER) | ReportServer |
SQL Server VSS Writer SQLWriter | SQLWriter |
Following are the few of SQL Server instance specific service names:
Display Name | Service Name |
---|---|
SQL Server (SQLEXPRESS | MSSQL$SQLEXPRESS |
SQL Server Agent (SQLEXPRESS) | SQLAgent$SQLEXPRESS |
Additional Notes:
If you try to start the SQL Server service which is already started you get the below error:
The requested service has already been started.
More help is available by typing NET HELPMSG 2182.
If you try to stop the SQL Server service which is not yet started you get the below error:
The SQL Server (MSSQLSERVER) service is not started.
More help is available by typing NET HELPMSG 3521.
If you try to start or stop SQL Server service when you do not have permissions you get the following error:
System error 5 has occurred.
Access is denied.
Resolutions:
1- Try to open command prompt as Administrator if it is not running in Admin mode.
2- Try to get Admin permissions on the Server.
If you try to start or stop SQL Server service when you do not have service installed you get the following error:
The service name is invalid.
More help is available by typing NET HELPMSG 2185.
Resolutions:
1. Check if SQL Server is installed on the server
2. Try to open command prompt as Administrator if it is not running in Admin mode.
3. Try to get Admin permissions on the Server.
2- Try to get Admin permissions on the Server.
Unable to start/stop any SQL Server sevice:
1. Check if the service name is correct.
You can use services.msc or use the command
[sourcecode language=”plain”]
sc query | findstr /I “MSSQL”
[/sourcecode]
2. Check if the Command prompt is in Admin mode
3. Check SQL Server error logs for additional details
For instances:
net start/stop [Service Name]
.. where [Service Name] can be obtained from the instance’s service (services.msc).
Example:
net start MSSQL$INSTANCE1