Tips ‘N’ Tricks – Windows – Starting, Stopping, and Restarting Services from Command Line
Most of the Softwares/Applications that we install on Windows, run as (have an associated) Windows Service(s) which are long running executables which run in their own sessions and do not require user intervention. These services can be Started, Stopped, or Restarted on a need by need basis depending upon whether you are running the application or not (whether you need to use that application or not).
Like any other software, there are many Windows Services associated with SQL Server, depending upon the components that are installed like Database Engine, Integration Services, Analysis Services, and Reporting Services etc. And since these services are long running executables which run on their own in the background, they use some amount of system resources even when you are not using the corresponding application/piece of software, as a result the system performance might get impacted. Also sometimes you might need to turn off some service which is not required, you may need to restart some service for certain changes to take effect and so on. To address this, often we follow the below listed steps to Start/Stop/Restart a Windows Service:
Go to Control Panel | Administrative Tools | Services (or Alternatively type services.msc in Run command and hit enter).
Right-Click on a Service and select from the available options: Start, Stop, Pause, Resume, and Restart
This is the usual approach and works just fine. But some people are more comfortable doing things pretty much from Command Prompt. Windows provides a set of commands to address this very need of controlling the services from Command Prompt.
To Stop a Service: Type NET STOP “SQL Server (MSSQLSERVER2K8R2)”
To Start a Service: Type NET START “SQL Server (MSSQLSERVER2K8R2)”
To Restart a Service, you can run the above two commands one after the other.
Similarly there are commands like NET PAUSE, NET CONTINUE etc. For more information, visit this msdn article.
To simplify this further, I have created batch files to Start, Stop, and Restart each of the Windows Services associated with SQL Server. My list of batch files looks something as shown below:
To make best use of the available system resources, I always turn off the Windows Services which I don’t need like if I am working on an ETL project, the probability of me using Reporting Services or Analysis Services will be very minimal and on a need by need basis, hence I turn them off 🙂
Note: The above steps are based on a Named Instance of SQL Server installed on Windows XP. The steps should be pretty much same for any version of SQL Server or any Windows Service in general.
Take a look at the other Tips and Tricks in this Series on Tips, Tricks, Techniques, and Shortcuts to Improve Productivity, and Design and Coding Skills.
Posted on June 6, 2012, in Shortcuts, SQL Server, SSAS, SSAS Tips, SSIS, SSIS Tips, SSRS, SSRS Tips, Tips 'N' Tricks, Windows, Windows Tips and tagged Analysis Services, Command Prompt, Commands, Database Engine, Integration Services, Reporting Services, Shortcuts, SSAS, SSIS, SSRS, System Performance, Tips, Tips and Tricks, Tricks, Windows, Windows Service. Bookmark the permalink. 2 Comments.