sp_notify_operator (Transact-SQL)
Sends an e-mail message to an operator using Database Mail.
Sends the message specified to the e-mail address of the operator specified. If the operator has no e-mail address configured, returns an error.
Database Mail and a mail host database must be configured before a notification can be sent to an operator. For more information, see Database Mail How-to Topics.
By default, members of the sysadmin fixed server role can execute this stored procedure. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:
SQLAgentUserRole
SQLAgentReaderRole
SQLAgentOperatorRole
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
The following example sends a notification e-mail to the operator François Ajenstat using the AdventureWorks2008R2 Administrator Database Mail profile. The subject of the e-mail is Test Notification. The e-mail message contains the sentence, "This is a test of notification via e-mail."
USE msdb ; GO EXEC dbo.sp_notify_operator @profile_name = N'AdventureWorks2008R2 Administrator', @name = N'François Ajenstat', @subject = N'Test Notification', @body = N'This is a test of notification via e-mail.' ; GO
