Sql-server – Alerts from Maintenance Plans

maintenance-planssql server

I would like to setup alerts from within the maintenance plans.
When you setup a notification from the Agent Job it sends out the Job name, duration, status, message.

If I add a Notify Operator Task it want's a subject and body. Will it still include the above information?

If not how can I have this information included?

Best Answer

Since the Maintenance Plan uses EXECUTE msdb.dbo.sp_notify_operator @name=N'some operator',@subject=N'some subject',@body=N'some body' there is no way to automatically include details about the Job Name, duration, status, etc. You could add a "on failure" precedence constraint that only executes the Notify Operator Task when a step in the maintenance plan fails. You could hard-code the Notify Operator Task with a specific message indicating the piece of the maintenance plan that failed. This will get pretty odious very fast, and still doesn't allow automating the error message you receive via email. This looks like:

enter image description here

Having said that, instead of using the built-in Maintenance Plans feature, you may want to look into Ola Hallengren's scripts that are built for this purpose, and offer a far wider range of options. You could then use standard Agent notification for the maintenance plan the way you do for other jobs.

http://ola.hallengren.com/