Wow, I just found this extended sproc tonight. I’m pretty estatic about it! xp_servicecontrol allows you to query the status of a windows service. In the past, I’ve used the ‘sc query
xp_serviceControl querystate, MSSQLSERVER
Other parameters are:
Stop
Start
Pause
continue
querystate
regarding xp_serviceControl: It doesn’t seem to work very well when a server is in cluster. Any service you attempt to stop with this xproc will give you the error:
Message
Executed as user: DMN\_DBA-OPS. StartService() returned error 5040, ‘The cluster node already exists.’ [SQLSTATE 42000] (Error 22003). The step failed.
For SQL servers in that are in a cluster, you should still use ‘sc \\servername query|stop|start serviceName’