SQL SERVER – 2005 – Start Stop Restart SQL Server From Command Prompt

Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy.

Click Start >> Run >> type cmd to start command prompt.

Start default instance of SQL Server
net start mssqlserver

Stop default instance of SQL Server
net stop mssqlserver

Start and Stop default instance of SQL Server.
You can create batch file to execute both the commands together.

Reference : Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – UDF – User Defined Function – Get Number of Days in Month
Next Post
SQLAuthority News – Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide

Related Posts

113 Comments. Leave new

  • Shadab Shah
    May 28, 2012 12:07 pm

    I am a newbie to this sql server stuff. i would like to know the practical reasons for which we would restart our sql server in production environment.

  • Hi Pinal,

    i have one doubt. ie. if sql server restarts , buffer cache will be cleared?
    please clarify me.


  • Hello, pls can anybody help me, i want to run DBCC CHECKDB in my SQL Server (MSSQLSERVER) from command prompt……its giving me the error below but when i try to run from command prompt it won’t let me. Pls find below…i need answers as soon as possible:
    (The operating system returned error 23(error not found) to SQL Server during a read at offset 0x0000002c73e000 in file ‘c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\cmedb.mdf’. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.)

  • Hello Pinel : can you please tell me how to determine who restarted SQL Server please.

  • Hello Everyone,

    I have MSSQL Server 2000 SP2 on Windows Server 2003, and use Windows Schedule Task with Batch Process to stop and restart my MSSQL services.

    The bacth process syntax :
    ECHO Stoping SQL SERVER Agent
    REM cls

    ECHO Stoping SQL SERVER Database
    REM cls

    ECHO Start SQL SERVER Database
    REM cls

    ECHO Start SQL SERVER Agent
    REM cls

    REM cls
    ECHO Finish Sequence

    It turn out well, but then recently I got error of :

    17113 :
    initconfig: Error 32(The process cannot access the file because it is being used by another process.) opening ‘C:\Program Files\Microsoft SQL Server\MSSQL\data\master.mdf’ for configuration information.

    And my SQL Server Service couldn’t start until I manually start the SQL Server service and SQL Server Agent service by the SQL Service Manager…

    Can anyone help me with this?
    How can I know what process that use the master.mdf file?

    Thank you


  • This is awesome along with everything else from Pinal Dave.



  • Good! Thanks…

  • can anyone please tell me what is the error code which comes in informatica if sql server is down? i mean if its shut down and we run a mapping then what error code it gives in session log? actually I have to build a session which checks the status of sql server 2008 whther its up or not, so I have to capture the error code of sql server down for that. any help would be appreciated!!

  • Could not start the SQL Server (SQLEXPRESS) in configration manager, the requiest fail, service did not respond in timely fashion. How we set State in running , I Checked Property of sqlexpress , should be local service

  • Hi sir I tried this but i found this message “Service could not be started” A specific error occurred : 3417

  • How to find who restarted SQL server

  • Hi, Can I automate the restart of sql server??

  • Wow this is an old post :D
    I use sc.
    sc start mssqlserver (to start)
    sc stop mssqlserver (to stop)
    sc query mssqlserver (to check status)
    sc \\remoteserver query msslqserver$instance (to check a remote named instance)

    You can automate a restart using these commands with windows scheduled tasks.

  • sql server was not started.

    in command prompt i type “net start mssqlserver” and press enter.
    i got the message: system error 5 has occured.
    Access is denied.

  • Hie Dave
    I lost my sql server enterprise manger short cut key from desktop. But still i can access the database and tables through Visual Studio ‘Server Explorer’. How shd i open sql server enterprise manger ?. I have tried ‘sqlwb’ & many commands in run prompt but nothing is working.. please help.. Thanx in advance Dave

  • why we use sqlwb for sql 2005 and ssms.exe for sql 2008R2??? please any body can explain me this????

  • in command prompt i type “net start mssqlserver” and press enter.
    i got the message: system error 5 has occured.
    Access is denied.

  • in my pc sql server agent automatically stopped when i shut down

  • Sampath Reddy Chandoor
    March 24, 2014 11:02 am

    Hi Pinal,

    in command line mode where the actions will be logged Windows application log or sql error log or some where else?

  • Too much Thank you Sir u are genius


Leave a Reply Cancel reply

Exit mobile version