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)






114 Comments. Leave new
I have SQL server installed on my person pc. I had stopped the server sometime back . Now when I open the Enterprise manager and starting the server, it is giving failed error. I have tried to start it many times but it says connection failed.
I have tried to give the command(net start mssqlserver) in run but it says service could not be started.
I also tried one more way but that also didn’t work, Here is that :
Create a batch file called RestartSQL.BAT with the following commands in it, and save it on the C:\ drive:
@ECHO OFF
NET STOP SQLSERVERAGENT
NET STOP MSSQLSERVER
NET START MSSQLSERVER
NET START SQLSERVERAGENT
Please help me how can we start this ?
Amit.
@Amit.
There could be many many reasons for this to happen.
I will list very important solution.
1. Go to Start
2. Go to Run
3. Type Services.msc
4(a). Search for SQL Server service ( if you have SQL Server 2005), double click this service.
4(b). Search for MSSQLServer service ( if you have SQL Server 2000), double click this service.
5. Check for Startup Type , this should not be disabled. This can be Manual or Automatic. If it is disabled, set it to manual, click apply, click Start, if the service starts, thats good, there is no more problem if not then proceed to step 6.
6. On the top of the same box, there is a LogOn Tab, click that tab, click local system, click apply click ok. If Service starts, then you have problem with the account under which Service is running, you should use a valid username and valid password.
Browse on internet for more information,
Should be straight forward.
Hope this helps,
IM.
muchisimas gracias maestro Imran Mohammed,
ya me iba a dormir super frustrado y cansado.
leyendo sus sabios consejos y aplicandolos se solucionó el problema q tenia con sql server.
nuevamente gracias desde venezuela.
manuel
Thank You Very much
Special thanks to Imran Mohammed Mine is Named Instance
Hi Dave,
I am in need to know one thing that is ther any way for intimation whenever any MSSQl Services stopped some one or server was restarted unexpected and MSSQL Server agent is not started as like when any SQL agent job failed it intimated to defined group by the help of operator.
Do you have any SQL script for above requirement, Please guide me or send me on email ID.
Please do not suggest any monitoring tools because of we have already configuring. SQL script is Just for backup of monitoring tool is failed.
Thanks in advance…
Anurag Tripathi
Don’t bother running on two lines with this, just do:
net stop mssqlserver && net start mssqlserver
I NEED TO REMOVE SQL SERVER AND INSTALL NEW SQL SERVER BUT SQL SERVER IS NOT REMOVE FROM MY COMPUTER
FATAL ERROR IS COMING.
for starting and stopping remote SQL server, we can use the command –
SC \\servername start mssqlserver
SC \\servername stop mssqlserver
For MSSQL Server agent , use
SC \\servername start sqlserveragent
SC \\servername stop sqlserveragent
I’m very impressed u website. This is the best site of world for helping purpose.
Warm Regard,
rajesh
It works for sql sever 2005, but how to make it works in sql server 2008 express?
net start MSSQL$SQLEXPRESS to start/stop sql express
Hi,
i have problem with starting SQlserver 2005 in my system (vista). When I am trying to start by these steps, I am getting following error.
a service specific error occurred: 17051
More help is available by typing NET HELPMSG 3547.
Even I am not able to start services from Configuration manager.
Please help me out to resolve problem.
@Imran Mohammed
Thank you for this outstanding comment — Using cmd to stop/start a named instance.
It’s really a pain in the […] to use UI to do such a simple task :)
Thanks again
HI,
What happens when the agent is restarted? I mean, what does it clear, what does it do?
I have an issue of a job, that does not complete – runs indefinitely. But when I restart the agent and then run the job, it completes. Again, if I attempt to run the job, it keeps running. I restart the agent, it completes!
I am curious to know what happened when I restarted the SQL Agent Service, that made it run?
My company server went down with a corrupted harddrive. We reinstalled the backup of the C: drive from an image but now SQL Express 2005 won’t start. I manually tried to start it but it gives an error message “Windows could not start SQL Server (SQLEXPRESS) on Local Computer…….error code 17051”. I looked up this code on the net and it says the evaluation copy has expired. I thought SQL Express was free and it is working until the C: Drive went down. Any ideas on how to proceed?
Thank you for the straight-to-the-point restart instructions. We have to restart the database services quite often on a couple of our systems and your instructions on how to put the restart in a batch file were very helpful. Thanks!
very nice discussion.
for schedule back up of your application add RestratSQL.bat
in schedule task
Hey Amit,
Is it good practices to restart the SQL Server 2008 services every week once a week?
Please note: our db’s use a lot of the tempDB’s
Thanks,
Dhaval
How can allow Remote Connection from command prompt
Can i stop/start the service using client ?
Hello Abhishek,
SQL Server service can be started or stopped from remote machine using NETSVC utility. For more details please visit the below page:
https://support.microsoft.com/en-us/help/125627
Regards,
Pinal Dave