Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Scheduling Shutdown Of SQL

Author  Topic 

adidas_kid
Starting Member

1 Post

Posted - 2006-05-18 : 15:33:39
I am trying to schedule the shutdown of SQL. I use the net stop in a .cmd file. The problem I am running into is there are dependancies that also need to be stopped. When run from a command line, it asks if I want to shutdown the other services.

How do I pass a "Y" and Enter into the .cmd file?

Stopping the other services first is not an option...

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-18 : 15:38:55
net stop mssqlserver /y

Tara Kizer
aka tduggan
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-19 : 00:52:56
Or you could NET STOP the other services first - that will be more important if you are planning to also restart them with NET START because starting the main service will not usually start the ancilliary services.

Here's what I use to "cycle" the SQL Services:

@ECHO OFF
ECHO.
ECHO This will Stop, and then Restart, SQL Services. press Control-C to abort
ECHO.
PAUSE

ECHO ----- Ignore "Folder already exists ..."
MD C:\LogFiles
ECHO ----- END Ignore
ECHO.
ECHO ---------- >>C:\LogFiles\RestartServices.LOG
ECHO Stop >>C:\LogFiles\RestartServices.LOG
DATE /T >>C:\LogFiles\RestartServices.LOG
TIME /T >>C:\LogFiles\RestartServices.LOG

ECHO.
ECHO Stopping SQL services ...
ECHO.
NET STOP "SQLSERVERAGENT" /Y
NET STOP "MSSQLSERVER" /Y

ECHO.
ECHO Ready to restart services - press Control-C to abort (with services STOPPED)
PAUSE

ECHO.
ECHO Starting SQL services ...
ECHO.
NET START "MSSQLSERVER"
NET START "SQLSERVERAGENT"

ECHO ---------- >>C:\LogFiles\RestartServices.LOG
ECHO Start >>C:\LogFiles\RestartServices.LOG
DATE /T >>C:\LogFiles\RestartServices.LOG
TIME /T >>C:\LogFiles\RestartServices.LOG
ECHO ========== >>C:\LogFiles\RestartServices.LOG

ECHO.
ECHO Services Restart completed
PAUSE

Kristen
Go to Top of Page

azmi
Starting Member

37 Posts

Posted - 2006-05-19 : 10:49:53
Very usefull batch files,i really do use this files.Thnks kristen. I will use this batch files to run in my schedule period..
Go to Top of Page
   

- Advertisement -