Version 2


    This alert uses the external stored procedure named xp_servicecontrol which is not supported. See this custom alert for an alternative: Monitor SQL Server Agent - No XP Proc


    This alert will run against the monitored instance and determine if the SQL Agent is Started or Stopped.  If Stopped, this alert will fire and send the appropriate emails. The alert can be created in Ignite by clicking on Alerts > Manage Alerts and creating a custom alert of type Custom SQL Alert - Single Boolean Return.


    SQL Statement


    CREATE TABLE #status (status VARCHAR(50))

    INSERT #status EXEC master..xp_servicecontrol 'querystate','SQLServerAGENT'

    SELECT CASE status WHEN 'Started' THEN 'TRUE' ELSE 'FALSE' END FROM #status

    DROP TABLE #status


    Alert Definition

    Monitor SQL Agent.jpg