Batch File To Start/Stop SQL Server
I figured this out a few years ago but forgot most of it. With a new blazing fast lap-top and only one instance of SQL Server running these services automatically at start-up wasn’t a big problem.
But now after installing SQL2012 I felt the need to set these services to manually start-up and wrote four batch-files:
- Start_SQL2008R2.bat
- Stop_SQL2008R2.bat
- Start_SQL2012.bat
- Stop_SQL2012.bat
Whenever I need one of these instances I right-click the relevant bat file and Run them as administrator.
This is the contents of Start_SQL2008R2.bat to start my SQL Server instanced with the name SQL2008R2.:
net start MSSQL$SQL2008R2
net start SQLAgent$SQL2008R2
net start MSOLAP$SQL2008R2
net start MsDtsServer100
net start ReportServer$SQL2008R2
pause
And this is the contents of my Stop_SQL2008R2.bat file.
net stop SQLAgent$SQL2008R2
net stop MSSQL$SQL2008R2
net stop MSOLAP$SQL2008R2
net stop MsDtsServer100
net stop ReportServer$SQL2008R2
pause
Notice the order (Stop SQL Agent now before SQL Server)