September 05, 2010

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.


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'


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


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.

About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

1 comment:

Maritey H said...

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