Restart SQL Server and SQL Server Agent from Command Prompt.

Many times I need to restart SQL Server service and SQL Server Agent service in my testing server.. Generally people used to go at Control Panel->Administrative Tools->Services, find SQL Server service or/and SQL Server agent service and start, restart or stop it. This is general practice but I would like to do this from command prompt itself.

Syntax is:

Net Stop mssql$YourSQLServerInstanceName
Net Start mssql$YourSQLServerInstanceName
Above command is used to start and stop SQL Server Service.  Now, here is the command for SQL Server agent.
Net Stop sqlagent$YourSQLServerInstanceName
Net Start sqlagent $YourSQLServerInstanceName
My instance name of SQL Server 2008 is “SQL2k8” so my command would be
Net Stop mssql$SQL2K8
Net Start mssql$SQL2K8
Net Stop sqlagent$SQL2K8
Net Start sqlagent $SQL2K8
Indeed I have one batch file which do this stuff for me. Just go to command prompt and run .BAT file is really easy than going to Control Panel->Administrative Tools->Services, find services and restart it.
Look at the screen below for more details.
Reference: Ritesh Shah
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of
Microsoft SQL Server Blog. Fight the fear of SQL with Founder is Ritesh Shah