Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

SQL Server Services Expand / Collapse
Author
Message
Posted Wednesday, February 25, 2009 5:56 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Good Day,

I am looking for small .bat code to find the status of SQL Server windows services.

In fact I have tried to find it on google but no luck

Appreciate if anybody can help with this.

Thanks in advance.

Cheers!!!



---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #664157
Posted Wednesday, February 25, 2009 10:47 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, August 1, 2014 6:18 AM
Points: 1,618, Visits: 20,980
There is useful command line utility called "SC". With this you can query the service status as below.

SC query mssqlserver


Hope this helps.

Cheers,

Pradeep


Pradeep Adiga
Blog: sqldbadiaries.com
Twitter: @pradeepadiga
Post #664795
Posted Thursday, February 26, 2009 8:19 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 1:01 PM
Points: 417, Visits: 1,149
I have uploaded an attachment of a .vbs file (I changed the extension to .txt for uploading) that I put together to monitor windows services every few minutes and e-mail me with any changes. I would run this through a scheduled task and it worked great. The only problem was that if the server was restarted for any reason, the job would not run and I would have to start it manually. The script may be useful for you anyway. If anyone can figure out why it won't restart automatically let me know.

  Post Attachments 
MonitorServicesScript.txt (106 views, 1.63 KB)
Post #665051
Posted Friday, February 27, 2009 4:45 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Thank you Adiga & rlondon.

Yes both of your reply will be useful.


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #665603
Posted Friday, February 27, 2009 8:44 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:57 AM
Points: 5,368, Visits: 9,917
Here's a way of doing it in T-SQL. Obviously it won't work if the SQL Server service itself isn't running!

EXEC master.dbo.xp_servicecontrol 'QUERYSTATE', 'SQLAgent'

John
Post #665799
Posted Sunday, March 1, 2009 10:55 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Thank you, John.

Your query works but in case if SQL server is down we won't be able to track it.

So any solutions are welcome; when SQL server stops :)


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #666356
Posted Tuesday, March 3, 2009 1:17 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, August 25, 2014 9:57 AM
Points: 1,081, Visits: 1,493
You can create a scheduled job in another sql server on another box. Create a link and then run a simple query like "select count(*) from linkname..sys.sysdatabases;". You can schedule the job to run every minute and if the job fails, notify you by email.

Tim White
Post #667612
Posted Tuesday, March 3, 2009 1:38 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 7:26 AM
Points: 4,358, Visits: 9,536
Using Powershell installed on any system that has network access:

PS> Get-WMIObject Win32_Service -computer {computer} | ? {$_.Name -like 'MSSQL*'} | Select Name, State

You can then extend this to send email what the state is not running, or you can issue a start, or anything else.


Jeffrey Williams
Problems are opportunites brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs
Post #667620
Posted Tuesday, March 3, 2009 2:30 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 6,366, Visits: 13,696
you could use VBS something along the lines of

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Service where displayname like '%sql%'",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_Service instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "DisplayName: " & objItem.DisplayName
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "ProcessId: " & objItem.ProcessId
Wscript.Echo "Status: " & objItem.Status
Next


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #667663
Posted Wednesday, March 4, 2009 5:26 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Hello '2 Tim 3:16',

Nice solution We can cerate the link server and surely it works but what if customer do not agree for link server?

Also due to some security issues some of the client do not allow linked server :)

Thank you Jeffrey & Perry for your inputs.

Cheers!!!


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #668043
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse