Friday, February 10, 2012

check the status of SQL Agent

Hi all

In my project, i need to call some jobs to finish some things. But sometimes, Sql Agent is not run. I need to check the status of it. Are there some functions or other ways to check it. if you know, please response me.

thank you !

You can use this script

declare @.service nvarchar(100)

select @.service = case when charindex('\',@.@.servername)>0
then N'SQLAgent$'+@.@.servicename
else N'SQLSERVERAGENT' end

exec master..xp_servicecontrol N'QUERYSTATE', @.service|||Great answer, thank you !

No comments:

Post a Comment