xp_serviceControl

April 18th, 2008 by Mr.M | 1 Comment »

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 ‘ via a cmdline. Now I can do it without having to open up a cmd prompt.

xp_serviceControl querystate, MSSQLSERVER

Other parameters are:

Stop
Start
Pause
continue
querystate

One Response to “xp_serviceControl”

  1. Obe says:

    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’

Leave a Reply

You must be logged in to post a comment.