Email Alerts when something goes wrong with SQL Server

Here’s how to configure your SQL Server to send alert notifications when something goes wrong.

Step 1: Define an Operator. Open SQL Server Management Studio (SSMS) 2008 > Expand SQL Server Agent Node > Right click on Operators > New Operator > Enter a Name of the operator in the Name section. Provide an E-mail address, Net send address, or Pager address or all the three the operator.

For this example, I am using only the E-mail address as shown below. Click OK.

image

Step 2: Let’s now define a new alert. This alert could be based on an error code or severity, or SQL Server performance or WMI event alert.

Right click the Alerts folder > New Alert > define an alert name > choose ‘SQL Server Event alert’ as the alert type > choose ‘all databases’ and in the severity, choose 011 – to raise an error when a specified database object is not found'

image

Select the Response tab now > check the ‘Notify operators’ checkbox and select Admin from the operator list with the Email option.

image

Click OK and an alert has been set. You should be receiving emails now whenever a query fails because of a missing database object. Make sure you have set up SQL Server Database Mail for the email to work.

1 comment:

  1. bravo! I always wanted to do something like this can you also show how to do database mail?

    ReplyDelete