Monitor, Start, Stop SQL server services in query analyzer.


Monitor Sql Server Services:

exec xp_servicecontrol 'querystate','mssqlserver'

exec xp_servicecontrol 'querystate','sqlserveragent'

exec xp_servicecontrol 'querystate','sqlbrowser'

exec xp_servicecontrol 'querystate','msdtc'

exec xp_servicecontrol 'querystate','MSSQLserverOLAPservice'

exec xp_servicecontrol 'querystate','Reportserver'

--Output :
Current Service State
------------------------------------------------------------------------------------------------------------------------------------
Running.

(1 row(s) affected)

For non sql services:

exec xp_servicecontrol ‘querystate’,'DHCPServer'


Start and Stop Sql services:

exec xp_servicecontrol ‘START’,'mssqlserver'

exec xp_servicecontrol 'STOP','sqlserveragent'


Hope above query will be useful to check sql server services state without service console help.

Comments

Popular posts from this blog

SQL Server:Steps to Configure Database Mirroring by T-SQL Script.

SSIS2008R2 Error: 0xC0209303 at Package: