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.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
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 :-) .

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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

boridom2006Author Commented:
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?

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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


boridom2006Author Commented:
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.

boridom2006Author Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.