Posts

Showing posts from May, 2011

Maintenance Plan history

I have been researching for the last couple of weeks a way to acquire a maintenance plan job history, success or failure. After alot of searching and finding that no one has or is not sharing the ability to do this, I decided to start hacking away at the MS SQL 2005/2008 core databases to find the relationship. After much digging, there are a total of 4 tables you need to have access to, whether through a proxy account of dbo schema account. Tables in question: - msdb..sysmaintplan_log - msdb..sysmaintplan_logdetail - msdb..sysmaintplan_subplans - msdb..sysjobs (optional: gives the SQL Agent Job name) SQL Script as i built it, but you will probably modify it to your needs: 1: SELECT 2: mpld.server_name, 3: j.name, 4: mpl.start_time, 5: mpl.end_time, 6: mpl.succeeded, 7: mpld.error_number, 8: mpld.error_message, 9: mpld.line1 + char(10) + char(13) + 10: mpld.line2 + char(10) + char(13) + 11: mpld.line3 + ch