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

SSIS2008R2 Error: 0xC0209303 at Package:

SQL2008R2 Error: The remote copy of database "XXXXX" has not been rolled forward to a point in time that is encompassed in the local copy of the database log. (Microsoft SQL Server, Error: 1412)