The name of the alert. The name appears in the e-mail or pager message sent in response to the alert. It must be unique and can contain the percent (%) character. name is sysname, with no default.
[ @message_id = ] message_id
The message error number that defines the alert. (It usually corresponds to an error number in the sysmessages table.) message_id is int, with a default of 0. If severity is used to define the alert, message_id must be 0 or NULL.
Only sysmessages errors written to the Microsoft Windows application log can cause an alert to be sent.
[ @severity = ] severity
The severity level (from 1 through 25) that defines the alert. Any SQL Server message stored in the sysmessages table sent to the Microsoft Windows application log with the indicated severity causes the alert to be sent. severity is int, with a default of 0. If message_id is used to define the alert, severity must be 0.
[ @enabled = ] enabled
Indicates the current status of the alert. enabled is tinyint, with a default of 1 (enabled). If 0, the alert is not enabled and does not fire.
The wait period, in seconds, between responses to the alert. delay_between_responsesis int, with a default of 0, which means there is no waiting between responses (each occurrence of the alert generates a response). The response can be in either or both of these forms:
One or more notifications sent through e-mail or pager.
A job to execute.
By setting this value, it is possible to prevent, for example, unwanted e-mail messages from being sent when an alert repeatedly occurs in a short period of time.
Is an optional additional message sent to the operator as part of the e-mail, net send, or pager notification. notification_message is nvarchar(512), with a default of NULL. Specifying notification_message is useful for adding special notes such as remedial procedures.
Is whether the description of the SQL Server error should be included as part of the notification message. include_event_description_inis tinyint, with a default of 5 (e-mail and net send), and can have one or more of these values combined with an OR logical operator.
The Pager and net send options will be removed from SQL Server Agent in a future version of Microsoft SQL Server. Avoid using these features in new development work, and plan to modify applications that currently use these features.
[ @database_name = ] 'database'
The database in which the error must occur for the alert to fire. If databaseis not supplied, the alert fires regardless of where the error occurred. database is sysname. Names that are enclosed in brackets ([ ]) are not allowed. The default value is NULL.
The sequence of characters that the description of the SQL Server error must be like. Transact-SQL LIKE expression pattern-matching characters can be used. event_description_keyword_pattern is nvarchar(100), with a default of NULL. This parameter is useful for filtering object names (for example, %customer_table%).
[ @job_id = ] job_id
The job identification number of the job to run in response to this alert. job_id is uniqueidentifier, with a default of NULL.
[ @job_name = ] 'job_name'
The name of the job to be executed in response to this alert. job_nameis sysname, with a default of NULL.
Either job_id or job_name must be specified, but both cannot be specified.
[ @raise_snmp_trap = ] raise_snmp_trap
Not implemented in SQL Server version 7.0. raise_snmp_trap is tinyint, with a default of 0.
USE msdb ;
@name = N'Test Alert',
@message_id = 55001,
@severity = 0,
@notification_message = N'Error 55001 has occurred. The database will be backed up...',
@job_name = N'Back up the AdventureWorks2012 Database' ;