Administering SQL Server

Defining Alerts

Errors and messages, or events, are generated by Microsoft® SQL Server™ and entered into the Microsoft Windows® application log. SQL Server Agent reads the application log and compares events to alerts that you have defined. When SQL Server Agent finds a match, it fires an alert.

By default, the following SQL Server events are logged in the Windows application log:

Alerts must be defined before notifications can be sent. The primary attributes of an alert are name and event or performance condition specification.

Naming an Alert

Every alert must have a name. Alert names must be unique and can be no longer than 128 characters.

Selecting an Event

You can specify an alert to occur in response to one or more events. You specify the set of events to trigger an alert according to:

Selecting a Performance Condition

You can specify a performance condition to monitor by firing an alert when the performance threshold is reached. To set a performance condition you must define the following:

Creating a User-defined Event Message

You can create user-defined event messages if you have special event tracking needs that are not addressed by standard SQL Server event messages. User-defined event messages generate error numbers greater than 50,000. Additionally, you can assign them a severity level.

User-defined event messages must be unique and have a unique error number. They can each have a unique language.

Note  When using SQL Server Enterprise Manager, you should select the Write to Windows NT application event log option. By default, user-defined messages with severities less than 19 are not sent to the Windows application log when they occur and therefore do not trigger SQL Server Agent alerts.

If you administer a multiple language SQL Server environment, create user-defined messages in each of the languages you support. For example, if you are creating a new event message that will be used on both an English and a German server, use the same event number for both, but assign a different language for each.

To create an alert using an error number

Enterprise Manager

Enterprise Manager

Transact-SQL

SQL-DMO

To create an alert using severity level

Enterprise Manager

Enterprise Manager

Transact-SQL

SQL-DMO

To define the response to an alert

Enterprise Manager

Enterprise Manager

Transact-SQL

SQL-DMO

To create a user-defined event error message

Enterprise Manager

Enterprise Manager

Transact-SQL

To edit a user-defined event error message

Enterprise Manager

Enterprise Manager

Transact-SQL

To delete a user-defined event error message

Enterprise Manager

Enterprise Manager

Transact-SQL

To disable or reactivate an alert

Enterprise Manager

Enterprise Manager

Transact-SQL

SQL-DMO

See Also

xp_logevent

PAN>