4

Question

  • Is it safe to start & stop SQL's services using PowerShell's Start-Service and Stop-Service commands?
  • If not, is there a recommended way to start & stop SQL's services through automation?

Additional Info

We're in the process of creating scripts to bring down our systems cleanly before maintenance windows, then to bring them back up afterwards. By cleanly I mean it stops the application's services, then stops the database services (i.e. in dependency order), setting all to DISABLED, so that the infrastructure team can apply windows updates / perform any work, safely rebooting servers as required, before running the scripts to bring the system back up in the correct (dependency aware) order.

Our DBA mentioned that the correct way to stop services is through SQL's Configuration Manager; implying that that's different to just using services.msc (or for automation, powershell's stop-service / command line's sc \\someServer stop someService.

However I've not been able to find anything explicitly saying it's incorrect to start/stop services through the regular means, or what extra protection/functionality SQL Configuration Manager gives with regards to simply starting & stopping services.

6

You are safe either which way you go. SERVICES.MSC and POWERSHELL command lines are EQUAL functions to MSSQL Configuration manager...

Configuration manager is also used to control instances, etc etc but the function of starting and stopping a service is the same no matter which method you choose.

Some people have their own ways of doing things, for example to quit an application, you can do File > Exit. Or you can do ALT+F4, they are both the same function...

Please view this link below for additional information and helpful details. This covers all of the different methods (SQL configuration mgr, SSMS, Commandline etc)

https://msdn.microsoft.com/en-us/library/hh403394.aspx

UPDATE regarding Failover Cluster Instance...

If the instance is clustered, use of any of the above suggestions does not apply and should not be used. For a FCI you need to utilize Cluster Manager or the FailoverClusters PowerShell module commands.

  • 3
    You should caveat that if the instance is clustered, use of any of your suggestions does not apply and should not be used. A FCI you utilize Cluster Manager or the FailoverClusters PowerShell module commands. – Shawn Melton Nov 12 '15 at 15:17
1

The recommended way is to always use configuration manager for two reasons:

i) If you want to change the password, using configuration manager you don't need to restart sql engine or agent services for the new password to take in effect. More detail can be found here.

ii) If you are managing a sql cluster and try to modify the password through services.msc it will failover to another node during restart of node1, sql configuration manager avoids this.

That being said, i don't have a script to do all the tasks through configuration manager, would be interesting to know if someone has that :).

  • Thanks @firasathahmed. So if only stopping/starting services; not changing passwords; there's no issue to simply using standard windows service stop/start mechanisms. – JohnLBevan Nov 12 '15 at 16:26
-1

From Microsoft SQL server Configuration Tools and right click sql server services and stop.

OR Using Transact-SQL

SHUTDOWN;

To stop the Database Engine immediately, execute the following statement. SHUTDOWN WITH NOWAIT;

See the link Start, Stop, Pause, Resume, Restart the Database Engine

  • 1
    Please re-read the OP question, he was not asking for how to use configuration tools to start or stop services. "We're in the process of creating scripts to bring down our systems cleanly before maintenance windows, then to bring them back up afterwards. " – Hector Nov 12 '15 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.