
Explanation:
Step 1: Enable Database Mail
Database Mail must be enabled.
Step 2: Enable the email settings for the SQL Server Agent.
To send a notification in response to an alert, you must first configure SQL Server Agent to send mail.
Step 3: Create a job notification
Example:
-- adds an e-mail notification for the specified alert (Test Alert)
-- This example assumes that Test Alert already exists
-- and that Francois Ajenstat is a valid operator name.
USE msdb ;
GO -
EXEC dbo.sp_add_notification -
@alert_name = N'Test Alert',
@operator_name = N'Francois Ajenstat',
@notification_method = 1 ;
GO -
Reference:
https://docs.microsoft.com/en-us/sql/ssms/agent/notify-an-operator-of-job-status
https://docs.microsoft.com/en-us/sql/ssms/agent/assign-alerts-to-an-operator