现在的位置: 首页 > 综合 > 正文

The way to control your sql-server related services

2013年02月12日 ⁄ 综合 ⁄ 共 418字 ⁄ 字号 评论关闭

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.

抱歉!评论已关闭.