Solved

How to restart SQl server automatically

Posted on 2010-08-27
4
816 Views
Last Modified: 2012-06-27
I need a batch file or a script that can automatically start/stop SQL server (default instance), once every day. I tried "net stop mssqlserver", but when the batch file executes it ask for user input for yes/no, etc. I assume I need to add some switches..

I need to do this to clrear the tempdb once a day... because it's growing too big , and I don't have time to trace the problem.
0
Comment
Question by:techzone12
[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
4 Comments
 

Author Comment

by:techzone12
ID: 33543817
I created a batch file as follows:
net stop mssqlserver
net start mssqlserver

When I run the batch file, I am getting this message:

Restarting SQL server ...
The following services are dependent on the SQL Server (MSSQLSERVER) service.
Stopping the SQL Server (MSSQLSERVER) service will also stop these services.

   SQL Server Agent (MSSQLSERVER)

Do you want to continue this operation? (Y/N) [N]:

I want the batch file to run without user input.  Also is stopping this service will have impact on other services. Do they have to be restarted too?
0
 
LVL 10

Expert Comment

by:pai_prasad
ID: 33545596
you need to stop SQL Server Agent first and then MSSQLServer.
do this..


net stop SQLSERVERAGENT
net stop MSSQLServer

net start MSSQLServer
net start SQLSERVERAGENT

0
 
LVL 4

Expert Comment

by:MSSystems
ID: 33545604
Please try this
call net stop SQLSERVERAGENT
call net stop MSSQLSERVER
call net start SQLSERVERAGENT
call net start MSSQLSERVER
pause

Open in new window

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33546196
easier for  the "stop":http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_command_options.mspx?mfr=truenet stop MSSQLSERVER /yhowever, you will indeed need to start all the dependencies "by hand" anyhow, so you need to know (and keep the list updated) anyhow.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL QUERY 3 33
denied execute as 13 31
Database Mail Profiles 1 23
Need multiple Group By's 8 28
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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