Please Help. I have been trying this for the past 3 days.

I need to send an alert mail when the SQL Server Agent is not running. That is, there can be instances where SQL Server is is running, but Agent is not running. I need to set up the same as startup procedure to check whether the agent is disabled or not when the service starts.I had already made the procedure and set up the same as start up procedure. I had also made a job based on the same, but had not scheduled.

Thanks in advance. Please help

  • 1
    This sounds like a bad idea, startup procedures aren't meant for these types of checks. You should look into other monitoring solutions.
    – Tom V
    Feb 23, 2017 at 14:23

2 Answers 2


Instead of having SQL Server monitor one of its subprocesses, why don't you have a script at the operating system level - WMI, PowerShell, what have you - periodically poll the services to make sure Agent is running? This seems a lot more foolproof than a startup procedure (which only runs when the SQL Server service starts, and potentially will finish before Agent starts, so it's not going to catch many scenarios - like when Agent suddenly fails or is forcibly shut down without touching the SQL Server service).

A job is absolutely not the way to do this. How can a job tell you that SQL Server Agent is not running? Catch-22. That's like your car driving itself to go get gas when it is out of gas.

Also, creating a watchdog for the Agent service seems way too reactive to me. Have you looked into why the service isn't starting or is getting shut down? The Windows event logs should have information about this.

  • Powershell is a great tool to use for monitoring. You can also use the task scheduler to check for windows events to do this.
    – HunterX3
    Feb 23, 2017 at 14:26

The Agent service depends on the SQL Server service, so it may not yet be running when your startup stored procedure runs.

Probably better to monitor the service some other way. See a similar discussion at https://ask.sqlservercentral.com/questions/45434/can-i-set-up-an-alert-when-the-sql-agent-service-s.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.