SQL Server with Mr. Denny

Apr 9 2014   2:00PM GMT

Viewing Maintenance Plan Logs

Denny Cherry Denny Cherry Profile: Denny Cherry

SQL Server

For many of my customers I’ve got them setup to use maintenance plans because they are small shops without a DBA and the maintenance plans give them something visual which they can easily tweak later on if needed without having to have me come in to make a small change to their reindexing or backups, etc.

One of the big failings of the maintenance plans is the reporting in Management Studio. If you right click on a maintenance plan you get an option to view reports and it gives you a whole bunch of really nice info … sometimes. After the plan has been running for a while it just sits there not giving you any useful information. And that’s because the code behind the maintenance plan report page … SUCKS!

The process does a bunch of row by row querying instead of just dumping a single large recordset like any normal application. So how do you get that useful information from SQL Server. The query below will give you the exact same information that the GUI gives you, but without waiting forever for the GUI to open up. Just change the plan and subplan names to the ones that you are looking for and run the query.

ld.line1 AS [Line1],
ld.line2 AS [Line2],
ld.line3 AS [Line3],
ld.line4 AS [Line4],
ld.line5 AS [Line5],
ld.server_name AS [ServerName],
ld.start_time AS [StartTime],
ld.end_time AS [EndTime],
ld.error_number AS [ErrorNo],
ld.error_message AS [ErrorMessage],
ld.command AS [Command],
ld.succeeded AS [Succeeded]
msdb.dbo.sysmaintplan_plans AS s
INNER JOIN msdb.dbo.sysmaintplan_subplans AS sp ON sp.plan_id=s.id
INNER JOIN msdb.dbo.sysmaintplan_log AS spl ON spl.subplan_id=sp.subplan_id
INNER JOIN msdb.dbo.sysmaintplan_logdetail AS ld ON ld.task_detail_id=spl.task_detail_id
((sp.subplan_name= ‘Full’)and((s.name=’Backups’)))
[StartTime] DESC


 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: