liveBook · Manning

SQL Server Agent operator

As explained in 100 SQL Server Mistakes and How to Avoid Them

A SQL Server Agent operator is a configured notification recipient for SQL Server Agent alerts and jobs.

Mistake #1: treating an operator as the alert itself. An operator is the configured recipient; an alert must still be linked to that operator before notification occurs. section 7.2

Database Mail must already be configured and must use an existing SMTP relay. Prefer a group address or distribution list over one person, and avoid deprecated pager notifications. section 7.2

Pete receives a database alert

Create the operator, then attach it to an alert. The example uses Pete for a duplicate-sales-order alert in the MagicChoc database; production systems should use a maintained group address. section 7.2

Listing 7.11 Creating a SQL Server Agent operator
EXEC msdb.dbo.sp_add_operator 
     @name= ‚Pete' 
   , @enabled=1
   , @email_address= ‚pete@onehudredsqlmistakes.com' ;

Create an enabled SQL Server Agent operator with a Database Mail email address. section 7.2

Remember that SQL Server Agent alerts depend on events reaching the Windows application log. Raise custom errors with RAISERROR() WITH LOG when logging is required, even below severity 19. section 7.2

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Defines creation and alert linkage, but defers comprehensive Database Mail configuration.
Examples
Uses Pete, a duplicate-sales-order alert, the MagicChoc database, and sp_add_operator configuration.
What it assumes
Assumes configured Database Mail and SMTP access while teaching operator and alert creation.
What you can do after
Operate SQL Server Agent notifications by creating an operator and associating it with an alert.
How it connects
Connects SQL Server Agent alerts with Database Mail, SMTP relay, Windows application log, and RAISERROR.

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.