Automating Alerts

SQL Server Agent provides a great mechanism for sending alerts via email in response to various events. Once you’ve setup Database Mail, and configured a SQL Server Agent Operator, you should add alerts for severe errors that affect the health of your SQL Server. Creating Alerts can be tedious, but automating Alerts is simple, with the easy code below that automates creating alerts in response to critical events. Automating alerts is important because it provides a standardized Alert configuration that can be used by all the SQL Servers in your organization.

A Party Angling, by George Morland

A Party Angling, by George Morland

In current versions of SQL Server, the following alerts are automatically created for severity levels 17 through 25 that have at least a single error that will be logged to the event log. Errors that are not logged to the event log do not raise Alerts via SQL Server Agent.

The code uses the built-in functionality for adding alerts, sp_add_alert.

Check out the rest of our posts on SQL Server Agent!