We help IT Professionals succeed at work.


boridom2006 asked
Medium Priority
Last Modified: 2008-01-09
I need to schedule and submit a job from SQL server, to shut down SQL and wait for 60 minutes until some other tasks get performed on the server, then startup SQL after a wait of 60 minutes, and send an email to several users if SQL did not start up successfully.

Any assistance will be appreciated.


Watch Question

Senior DBA
Most Valuable Expert 2018
Distinguished Expert 2019
The shutdown can be done from w/i SQL, but the start up will have to be done via Windows.  Since SQL isn't up, it can't run a job to start itself :-) .

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
concur with scott.

An approach may be to schedule a batch file or VBA script to NET STOP sql server then WAIT then NET START  sql


I have the script to do it using NET STOP/START, but got requested to find out if there is a way in which it can be done using only SQL Server jobs only.  Any idea?

As Scott says,  its impossible for it to be in sql server because if sql is stopped then it cant start itsself.

do you need SQL server to be shut down completely or just have the User databases unavailable?

I agree with Scott.

maybe you don't need to shut down SQL Server completely, but only stop the usage of several databases?
if yes, you can create a SQL Batch job that detaches your database, waits and then attaches the db again

sp_detach and sp_attach are the keywords to search for in BOL




Thanks for all of your inputs.  It really sounds impossible for me as well, but the request I received was to completely shutdown all instances of sql server.  I have an idea that may work.  I will create an instance of sql only for administrative purpose, and from there will run a job to stop all other instances.  Does someone have an answer for the last portion of my question?  "send an email to several users if SQL did not start up successfully".  In other words, everytime I NET START one instance, need to check the status of the instance, and send email notifying if there was an instance that did not startup.


"I will create an instance of sql only for administrative purpose, and from there will run a job to stop all other instances."

Personally, I would go back to the requestee and explain the predicament and discuss alternative options like VB Script scheduled via Windows Scheduler.    Installing an additional instance of SQL for administrative purposes seems to me like a huge resource drain.


I agree with you, but I am dealing with a requestee that is not very flexible, for not saying not flexible at all.
Ok, In that case I dont see any other option but i would ensure you explain to the client / requestee that performance on his box will diminnish by having to have a second instance of sql on there.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.