Solved

SQL Server - Schedule Job to Stop and Restart service

Posted on 2014-12-01
3
518 Views
Last Modified: 2014-12-02
Hi..
How can I schedule a job to STOP and RESTART the sql server.
Having issues and would like to stop and restart at midnight.
thx
0
Comment
Question by:JElster
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 40474084
you cannot do that from within sql server / sql server agent.
this could only be done from OS level, using NET STOP and NET START commands (specifying the relevant server names)

however, the real question here is : why do you want to do that?
in 99.99% of the cases the reason why people want to do is because they are just trying to cure some symptoms not knowing the issue and the correct solutions for the (often even a non-)issue
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 250 total points
ID: 40474131
You can use a SQL job to stop SQL.

But you can't use a SQL job to start SQL, because SQL jobs require that SQL be up and running to process the job :-).

You could theoretically have the job that stops SQL create an NT job to start SQL in <nn> minutes after the current time, then stop SQL.  You need to allow enough time for SQL to stop -- which can vary slightly -- or put some type of loop in the NT job.
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 40475365
So, you are having issues and want to restart the service every night. What about trying to find the main problem and resolve it?
Soon you'll need to restart it in the middle of the day also and I think you won't want that, right?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now