Site icon GetCodify

How Start/Stop MS SQL Server Using .bat file in windows

MS SQL Server

If you are a stack developer who works on multiple platform for coding, might face this proble of starting and stoping the Sql Server, because if you want work in default port 80 for apache in php of any other, you have to stop the iis and SQL server to run apache in port 80 only, so while doing this to start/stop we use eather SQL Configuration manager/ windows services. so here we will tell you how to create a .bat file to start and stop all the sql services at once.

Follow the Steps below

  1. first, create a new file in notpad and save as start.bat file the just copy this below code to the same start.bat file and save.
    net start MSSQLSERVER
    
    net start "SQL Server Agent (MSSQLSERVER)"
    
    net start "SQL Server Browser"
    
    net start "SQL Server Analysis services (MSSQLSERVER)"
    
    net start "SQL Server Reporting Services (MSSQLSERVER)"
    
    net start "SQL Server Integration Services 11.0"
    
    net start "SQL Server Distributed Replay Client"
    
    net start "SQL Server Distributed Replay Controller"
    
    iisreset /start
    
    SQL and IIS start
  2. After saving first file create one more file called stop.bat using notepadand paste the below code.
    net stop MSSQLSERVER
    
    net stop "SQL Server Agent (MSSQLSERVER)"
    
    net stop "SQL Server Browser"
    
    net stop "SQL Server Analysis services (MSSQLSERVER)"
    
    net stop "SQL Server Reporting Services (MSSQLSERVER)"
    
    net stop "SQL Server Integration Services 11.0"
    
    net stop "SQL Server Distributed Replay Client"
    
    net stop "SQL Server Distributed Replay Controller"
    
    iisreset /stop
    
    to STOP SQL and IIS Server
  3. After completing creation of new files now when ever you need these file you have to right click on .bat file and run this file in Administrator mode by clicking on “Run as Administrator”.
    Note : in the above code i have used our SQL running server name “MSSQLSERVER”, this might be different in your PC. To check goto Run and type Services.msc in that file list of SQL services the you can find the SQL Instance name as shown in below image.

    SQL Server Services

 

 

Exit mobile version