Setup SQL Server 2008 Maintenance Plan Email Notifications

sql2008logo.jpgFor most of the SQL installs that I maintain, nightly SQL dumps to disk and then copy to tape is my preferred backup method. I use a simple maintenance plan that dumps all user databases to the local disk and then a cleanup task that purges backup files older than a set number of days. An email alert with either success or fail in the subject line is sent out after each maintenance plan task is completed. This article will review step by step how to add email notifications to your existing SQL 2008 maintenance plan.

First step is to configure Database Mail. Open Microsoft SQL Server Management Studio then right-click on Database Mail > select Configure Database Mail

dbemailconfig.jpg

Skip the welcome screen and select Next on the Select Configuration Task window.

dbmailwizard.jpg

Create new profile > fill out Profile name > Select Add under SMTP accounts:

newprofile.jpg

Fill out New Database Mail Account info:

smtpaccount.jpg

Configure Profile Security > check Public > set as Default > Next > Finish > close

publicprofile.jpg

Send test email. Right-click on Database Mail

dbemailconfigtest.jpg

Fill out test info, select Send Test Email. 

dbmailtest.jpg

Check inbox, select OK on the confirmation screen. If you dont recieve test email then double check and verify smtp settings.

testemailok.jpgNext step is to configure Operators. Under Object Explorer right-click on Operators > New Operator

newoperator.jpg

Fill out New Operator info (minimum name and email address)

sysadminproperties.jpg

Select OK.

sysadmin.jpgNext, right click on designated maintenance plan (assuming one is already configured) and select Modify

dbmaintmodify.jpg

This should bring up the design window with the current tasks

dbmaintplan.jpg

From the Toolbox window Drag and drop Notify Operator Task to Design window twice. One for success and the other for fail.

generaltools.jpg

Connect the backup database task to each Notify Operator Task and make sure the arrows are pointing down.

dbplanfinal.jpg

Designate one of the Notify Operator Task objects connection arrows as Failure. Right click on connection and select Failure. This will turn the connection arrow red.

connectionset.jpg

Double click each Notify Operator Task > check which operators to notify if there are more than one > fill out Subject and Body fields > select OK

notifyoperatortask.jpgSave Maintenance Plan and test.

successalert.jpgOne of the nice features of the Notify Operator Task in SQL 2008 that wasn't an option in SQL 2005 is the ability to add a unique subject line to the message. Its helpful to be able to see the success or fail status at a glance from just the subject line especially with the morning barrage of emails. Comments or questions welcomed. 

Related Entries

5 Comments

It's possible to backup remote network connection(not in local server connection).because i am trying to centralized backup.

On the backup database task it only allows you to select local drives. My central backup is scheduled to backup the local sql backup directory after the backup database task has completed.

Hi,

This is exactly what I was trying to do. I came accross this via Google. Thank you for taking the time to explain this.

Works perfect!

Thank you so much. Worked like a charm!

Great explanation, very useful. Thanks

Leave a comment

Recent Entries

Close