The way to control your sql-server related services

Sometimes you want to detect whether a service is running, and if not, you want to run it. Here is what you can do for the Sql Server Agent Service:

EXEC master.dbo.xp_ServiceControl 'QUERYSTATE','SQLServerAgent'
EXEC master.dbo.xp_ServiceControl 'START', 'SQLServerAgent'

But, xp_ServiceControl  is undocumented and unsupported; its behavior could change with a service pack or the next release of SQL Server. So now I am looking for some better solutions....
If you know, please tell me.

posted @ 2008-05-01 09:38  EagleFish(邢瑜琨)  阅读(431)  评论(0编辑  收藏  举报