Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-05-24 : 07:46:30
|
Sam writes "How can I detect when SQL Agent is stopped or started?We sell an SQL based application & occasionally the administrators at the customers site will stop SQL Agent. Of course it's my fault that the SQL jobs (backups or DTS pacakages) don't run. What I'd like to do is execute a VB script that sends out an email to notify me & local administrators that the agent is stopped. Sending another message that the agent is started would be a bonus.Thanks" |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-05-24 : 09:54:24
|
Use the agent to schedule a job that sends you an e-mail every hour or so. Then monitor for the reciept of that e-mail. |
 |
|
schuhtl
Posting Yak Master
102 Posts |
Posted - 2006-05-24 : 11:42:09
|
You can find the status of the SQL Agent by using the following undocumented sp. I am sure you are aware that undocumented sp's are not supported and can be discontinued at any time. EXEC master.dbo.xp_ServiceControl 'QUERYSTATE','SQLServerAgent' |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-24 : 12:20:04
|
[code]if exists ( select * from master.dbo.sysprocesses where program_name like 'SQLAgent - %') begin print 'Agent Running' endelse begin print 'Agent not Running' end[/code]CODO ERGO SUM |
 |
|
|
|
|