Define the Response to an Alert (SQL Server Management Studio)
This topic describes how to define how Microsoft SQL Server responds to SQL Server Agent alerts in SQL Server 2016 by using SQL Server Management Studio or Transact-SQL.
In This Topic
Before you begin:
To define the response to an alert, using:
The Pager and net send options will be removed from SQL Server Agent in a future version of MicrosoftSQL Server. Avoid using these features in new development work, and plan to modify applications that currently use these features.
Note that SQL Server Agent must be configured to use Database Mail to send e-mail and pager notifications to operators. For more information, see Assign Alerts to an Operator.
SQL Server Management Studio provides an easy, graphical way to manage jobs, and is the recommended way to create and manage the job infrastructure.
Only members of the sysadmin fixed server role can define the response to an alert.
In Object Explorer, click the plus sign to expand the server that contains the alert on which you want to define a response.
Click the plus sign to expand SQL Server Agent.
Click the plus sign to expand the Alerts folder.
Right-click the alert on which you want to define a response and select Properties.
In the alert_namealert properties dialog box, under Select a page, select Response.
Select the Execute job check box and, from the list below the Execute job check box, select a job to execute when the alert occurs. You can create a new job by clicking New Job. You can view more information about the job by clicking View Job. For more information about the available options in the New Job and Job Propertiesjob_name dialog boxes, see Create a Job and View a Job.
Select the Notify Operators check box if you want to notify operators when the alert is activated. In the Operator list, select one or more of the following methods for notifying the operator or operators: E-mail, Pager, or Net Send. You can create a new operator by clicking New Operator. You can view more information about an operator by clicking View Operator. For more information about the available options in the New Operator and View Operator Properties dialog boxes, see Create an Operator and View Information About an Operator.
When finished, click OK.
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute.
-- adds an e-mail notification for Test Alert. -- 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
For more information, see sp_add_notification (Transact-SQL).