The first step in creating a SQL Server
alert is to create an Operator. An Operator is the person, or people,
who will receive an alert when one is raised. We create an operator by
executing the sp_add_operator system stored procedure in Management Studio. The following is an example of the syntax of this system stored procedure:
sp_add_operator [Operator Name],[Enabled],
[Email Address],[Pager Address],
[Weekday Pager Start],[Weekday Pager End],
[Saturday Pager Start],[Saturday Pager End],
[Sunday Pager Start],[Sunday Pager End],
[Available Pager Days],[Netsend Address],
[Category]
This system stored procedure's arguments are as follows:
Operator Name – the textual reference to the Operator.
Enabled– indicates whether the Operator can receive notifications.
Email Address
– the e-mail address to which notifications are sent for this Operator.
This argument is only necessary when notifying through e-mail.
Pager Address
– all pager notifications are sent through the e-mail system. The value
of this argument will need to be the e-mail account of the pager that
will receive notifications. This argument is only necessary when
notifying through a pager.
Weekday Pager Start/End
– the time of day during the weekday that notifications can be
received. The value must be in the format of HHMMSS (Hour, Minute,
Second). 0 indicates midnight. Despite this argument having the word
"Pager" in it, it applies to e-mail notifications as well. This argument
is only necessary when the Operator is active on weekdays.
Saturday Pager Start/End–
the time of day on Saturday that notifications can be received. This
argument is only necessary when the Operator is active on Saturdays.
Sunday Pager Start/End–
the time of day on Sunday that notifications can be received. This
argument is only necessary when the Operator is active on Sundays.
Available Pager Days–
this indicates the days on which the Operator is available to receive
notifications. This value ranges from 0 to 127. This value is determined
by adding the assigned values of the days available. These assigned
values are: Sunday (1), Monday (2), Tuesday (4), Wednesday (8), Thursday
(16), Friday (32) and Saturday (64). For example: if an Operator is
only available on Monday, Wednesday and Friday, this value would be 42
(2+8+32).
Netsend Address – the network address to which a notification is to be sent. This argument is only necessary when notifying through net send.
Category – the category of the Operator. This argument is optional.
Listing 1 shows how to create an operator for the DBA, called DBA1, in the msdb
database. Of course, our intrepid DBA is always on call and so they are
available everyday at all hours. Not that long ago, the DBA would have a
pager strapped to them to receive very basic notifications. These days
the availability of email, along with the multi-functional benefits of
the cell phone, provide a means to receive a detailed email message
quickly; therefore, the notification in our example will be sent via
email.