Solved

SQL Server - Schedule Job to Stop and Restart service

Posted on 2014-12-01
3
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

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:Scott Pletcher
Scott Pletcher 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 49

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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