SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to start & Stop all SQL services in one go
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Aged Yak Warrior

India
547 Posts

Posted - 08/10/2010 :  07:02:21  Show Profile  Reply with Quote
Hi All,

Do we have any command which start and Stop all SQL related services in one go ?

Thanks,
Gangadhar

Lumbago
Norsk Yak Master

Norway
3271 Posts

Posted - 08/10/2010 :  08:54:51  Show Profile  Reply with Quote
What do you mean by "in one go"? Does it have to happen at the same time or can it be in sequence? If in sequence is good enough you can write a simple bat-script to do it for you I guess.

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

ramforlak
Starting Member

India
2 Posts

Posted - 08/10/2010 :  09:33:03  Show Profile  Reply with Quote
You can start by using dynamic services ..You can find this in services.msc...
check it

Ramachandra
Go to Top of Page

SQLvariant
Starting Member

USA
5 Posts

Posted - 08/11/2010 :  11:53:44  Show Profile  Reply with Quote
You can certainly do this with PowerShell.

To stop all of the SQL Services on a machine you would just do:
Get-Service *SQL* | Stop-Service -Force


Now if you wanted to restart all of your SQL Services but didn't want to start any SQL Serveices that were currently stopped you would just run:
Get-service *SQL* | where-object {$_.Status -eq "Running"} | Restart-Service -Force


And I'm pretty sure that you're going to have to run both of those commands from an elevated shell (meaning that you'll have to right-click on PowerShell and select "Run as Administrator").

Aaron Nelson - @SQLvariant
http://sqlvariant.com/wordpress/
Go to Top of Page

Lumbago
Norsk Yak Master

Norway
3271 Posts

Posted - 08/12/2010 :  03:06:50  Show Profile  Reply with Quote
Ah...gotta love powershell! Too bad I haven't had much time working with it

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

Kristen
Test

United Kingdom
22415 Posts

Posted - 08/12/2010 :  04:16:25  Show Profile  Reply with Quote
Isn't that liable to start them in an order that is not parent-then-child?

FWIW we have a Batch file that stops all the services, in desired order (SQL Agent before SQL Service) and then restarts them (in the reverse order). I have a shortcut to that batch file on the desktop ...
Go to Top of Page

SQLvariant
Starting Member

USA
5 Posts

Posted - 08/12/2010 :  08:11:17  Show Profile  Reply with Quote
quote:
Originally posted by Kristen

Isn't that liable to start them in an order that is not parent-then-child?


I was worried about that very same problem so I tested it on my local machine using the -Force parameter and all of my services came back up just fine. If you run into a problem with it let me know and I will figure out how to force the dependencies in order too.

But again, as my developers always say 'it worked fine on my machine'


Aaron Nelson - @SQLvariant
http://sqlvariant.com/wordpress/
Go to Top of Page

SQLvariant
Starting Member

USA
5 Posts

Posted - 08/12/2010 :  13:21:58  Show Profile  Reply with Quote
quote:
Originally posted by Kristen

Isn't that liable to start them in an order that is not parent-then-child?


I tested it out one more time to verify. Turns out that if you run it without the -Force it won't even let you stop the service and gives you this error message:
Restart-Service : Cannot stop service 'SQL Server (KILIMANJARO) (MSSQL$KILIMANJARO)' because it has dependent
services. It can only be stopped if the Force flag is set.


But when you run it with the -Force it restarts them with the dependency order factored in and gives you this meaage:
WARNING: Waiting for service 'SQL Server (KILIMANJARO) (MSSQL$KILIMANJARO)' to finish stopping...
that finally goes away when the dependent services are able to start.

Aaron Nelson - @SQLvariant
http://sqlvariant.com/wordpress/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000