Solved

Shutting down SQL server before a  powerfailure

Posted on 2001-09-05
4
399 Views
Last Modified: 2008-02-26
I have a UPS software which allows me to run a script (.bat) in NT/Windows 2000 just before shutting down windows in the event of a power failure.

1. If I shut down windows without bringing MSSql down, does it cause problems? Or is SQL brought down safely by NT itself before shutting down?

2. What command can I use in the batch file to bring down SQL safely?
0
Comment
Question by:raj_nbr
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6459696
Normally, SQL Server runs as a service, and is requested by Windows to shutdown whenever windows goes down...
Now if you want to stop SQL Server by bat file, simply put this command:
NET STOP MSSQLSERVER

This will stop all the services related to SQL Server too:
MS SQL Server agent, for example, and any other service that marked sqlserver as dependency

Cheers
0
 

Expert Comment

by:racosta
ID: 6460577
If the SQLServerAgent is started, and you execute NET STOP MSSQLSERVER, it's gonna ask you to also shutdown the SQL Server Agent service, but if the process is in background, you wont'n be able to answer the question and it won't work.
  First execute NET STOP SQLSERVERAGENT (if it is already sttoped it will give an error but it will continue) and then NET STOP MSSQLSERVER.

   But the Server it selfs shutdowns all the services before a normal shutting down. If a power failure happens, then the server won't shutdown ok, but when it raise up, rolls back all the uncommited transactions and rolls forward all the commited transactions.
 
  In this way, every finished transaction is like it was before power failure, and all the transactions that where running when the power failure happens, is like they never happened.

   
0
 
LVL 3

Author Comment

by:raj_nbr
ID: 6769186
This comment being the first one, gets selected.
0
 

Expert Comment

by:prjordan
ID: 8082661
would

NET START SQLSERVERAGENT
NET START MSSQLSERVER

get SQL back up running after it was stopped without a restart of the computer?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS 2013 - Overlapping reports 2 22
Help Required 3 97
TSQL query to generate xml 4 35
transaction in asp.net, sql server 6 33
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

809 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