sp_add_alert must be run from the msdb database.
These are the circumstances under which errors/messages generated by SQL Server and SQL Server applications are sent to the Windows application log and can therefore raise alerts:
-
Severity 19 or higher sysmessages errors
-
Any RAISERROR statement invoked with WITH LOG syntax
-
Any sysmessages error modified or created using sp_altermessage
-
Any event logged using xp_logevent
SQL Server Management Studio provides an easy, graphical way to manage the entire alerting system and is the recommended way to configure an alert infrastructure.
If an alert is not functioning properly, check whether:
-
The SQL Server Agent service is running.
-
The event appeared in the Windows application log.
-
The alert is enabled.
-
Events generated with xp_logevent occur in the master database. Therefore, xp_logevent does not trigger an alert unless the @database_name for the alert is 'master' or NULL.