Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Sets up a notification for an alert.
sp_add_notification [ @alert_name = ] 'alert' ,
[ @operator_name = ] 'operator' ,
[ @notification_method = ] notification_method
[ ; ]
The alert for this notification. @alert_name is sysname, with no default.
The operator to be notified when the alert occurs. @operator_name is sysname, with no default.
The method by which the operator is notified. @notification_method is tinyint, with no default. @notification_method can be one or more of these values combined with an OR
logical operator.
Value | Description |
---|---|
1 |
|
2 |
Pager |
4 |
net send |
0
(success) or 1
(failure).
None.
sp_add_notification
must be run from the msdb
database.
SQL Server Management Studio provides an easy, graphical way to manage the entire alerting system. Using Management Studio is the recommended way to configure your alert infrastructure.
To send a notification in response to an alert, you must first configure SQL Server Agent to send mail.
If a failure occurs when sending an e-mail message or pager notification, the failure is reported in the SQL Server Agent service error log.
You can grant EXECUTE
permissions on this procedure, but these permissions might be overridden during a SQL Server upgrade.
The following example adds an e-mail notification for the specified alert (Test Alert
).
Note
This example assumes that Test Alert
already exists and that François Ajenstat
is a valid operator name.
USE msdb;
GO
EXEC dbo.sp_add_notification
@alert_name = N'Test Alert',
@operator_name = N'François Ajenstat',
@notification_method = 1;
GO
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today