select @@servername as ServerName, a.Name as JobName, a.enabled, a.start_step_id, b.message, b.run_status, b.run_date as RunDate, substring(replicate('0', 6 - len(b.run_time)) + cast(b.run_time as varchar), 1, 2) + ':' + substring(replicate('0', 6 - len(b.run_time)) + cast(b.run_time as varchar), 3, 2) + ':' + substring(replicate('0', 6 - len(b.run_time)) + cast(b.run_time as varchar), 5, 2) as RunTime, substring(replicate('0', 6 - len(b.run_duration)) + cast(b.run_duration as varchar), 1, 2) + ':' + substring(replicate('0', 6 - len(b.run_duration)) + cast(b.run_duration as varchar), 3, 2) + ':' + substring(replicate('0', 6 - len(b.run_duration)) + cast(b.run_duration as varchar), 5, 2) as DurationSec from msdb..sysjobs a with (nolock) join msdb..sysjobhistory b with (nolock) on a.job_id = b.job_id where run_status not in (1,4) and cast(cast(b.run_date as varchar) as datetime) > getdate() - 3 order by run_date desc, run_time desc select @@servername as ServerName, a.Name as JobName, a.enabled, a.start_step_id, b.message, b.run_status, b.run_date as RunDate, substring(run_time, 1, 2) + ':' + substring(run_time, 3, 2) + ':' + substring(run_time, 5, 2) as RunTime, b.run_duration as DurationSec from msdb..sysjobs a with (nolock) cross apply ( select top 15 b.message, b.run_status, cast(b.run_date as varchar) as run_date, replicate('0', 6 - len(b.run_time)) + cast(b.run_time as varchar) as run_time, b.run_duration from msdb..sysjobhistory b with (nolock) where b.step_id = 0 and a.job_id = b.job_id order by run_date desc, run_time desc ) b where run_status <> 1 and cast(cast(b.run_date as varchar) as datetime) > getdate() - 2 order by name, run_date desc, run_time desc go create table #errorlog(logdate datetime, processinfo varchar(255), info varchar(MAX)) insert into #errorlog exec xp_readerrorlog select * from #errorlog where logdate > getdate() - 2 and left(info, 29) <> 'Log was backed up. Database: ' and left(info, 20) <> 'Starting up database' and left(info, 28) <> 'Log was restored. Database: ' and right(info, 34) <> 'does not allow recovery to be run.' and info <> 'Error: 18456, Severity: 14, State: 8.' and info <> 'Error: 18054, Severity: 16, State: 1.' and LEFT(info, 11) <> 'Error: 6000' and LEFT(info, 3) <> 'IDS' and info <> 'Error: 18452, Severity: 14, State: 1.' and info <> 'Error: 17806, Severity: 20, State: 14.' -- and info like '%request%' order by logdate drop table #errorlog