Setup SQL Server 2008 Maintenance Plan Email Notifications

时间:2023-03-09 22:34:16
Setup SQL Server 2008 Maintenance Plan Email Notifications

一条龙作完,如何设置EXCHANGE的操作员邮件通知。。

~~~~

http://808techblog.com/2009/07/setup-sql-server-2008-maintena.html

For 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

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

Fill out New Database Mail Account info:

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

Send test email. Right-click on Database Mail

Setup SQL Server 2008 Maintenance Plan Email Notifications

Fill out test info, select Send Test Email.

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email NotificationsNext step is to configure Operators. Under Object Explorer right-click on Operators > New Operator

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

Select OK.

Setup SQL Server 2008 Maintenance Plan Email NotificationsNext, right click on designated maintenance plan (assuming one is already configured) and select Modify

Setup SQL Server 2008 Maintenance Plan Email Notifications

This should bring up the design window with the current tasks

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email Notifications

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.

Setup SQL Server 2008 Maintenance Plan Email Notifications

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

Setup SQL Server 2008 Maintenance Plan Email NotificationsSave Maintenance Plan and test.

Setup SQL Server 2008 Maintenance Plan Email NotificationsOne 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.