Create a User-Defined Event

APPLIES TO: yesSQL Server yesAzure SQL Database (Managed Instance only) noAzure SQL Data Warehouse noParallel Data Warehouse

Important

On Azure SQL Database Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Database Managed Instance T-SQL differences from SQL Server for details.

You can create user-defined events if you want to monitor events other than events that are predefined by SQL Server. You can also assign a severity level to each user-defined event.

Note

When using SQL Server Management Studio, select the Write to Windows application event log option for each user-defined event message, to ensure that the messages are logged. By default, user-defined messages of severity lower than 19 are not sent to the Microsoft Windows application log when they occur. User-defined messages of severity lower than 19 therefore do not trigger SQL Server Agent alerts.

User-defined events must have a unique message number. Message numbers for a user-defined event must be greater than 50,000. You can define messages for the event in multiple languages. However, an En-US error message must exist before messages in other languages can be added.

If you administer a multiple-language SQL Server environment, create user-defined messages in each of the languages that are supported. For example, if you are creating a new event message to be used on both an English and a German server, use the same message number and severity for both, but assign a different language to each.

The following tasks provide information about how to create user-defined events and alerts that respond to them:

To create an alert based on a message number

To create an alert based on severity levels

To define the response to an alert

To create a user-defined event error message

To modify a user-defined event error message

To delete a user-defined event error message

To disable or reactivate an alert

See Also

sp_update_alert (Transact-SQL)