Solved

Shutting down SQL server before a  powerfailure

Posted on 2001-09-05
4
398 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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

920 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

16 Experts available now in Live!

Get 1:1 Help Now