Solved

SQL Server - Schedule Job to Stop and Restart service

Posted on 2014-12-01
3
500 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 45

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

14 Experts available now in Live!

Get 1:1 Help Now