Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select j.name Name, js.step_id Step, js.command Source, j.enabled Enabled, convert(char(16), date_created, 120) Created, convert(char(16), date_modified, 120) Modified,
- case jh.run_status when 0 then 'Failed' when 1 then 'Success' when 2 then 'Retry' when 3 then 'Canceled' when 4 then 'In progress' end LastStatus,
- convert(char(16),cast(stuff(stuff(cast(jh.run_date as varchar),7,0,'-'),5,0,'-') + ' ' + stuff(stuff(replace(str(jh.run_time,6,0),' ','0'),5,0,':'),3,0,':') as datetime),120) as LastRun,
- j.job_id
- from msdb..sysjobs j
- join msdb..sysjobsteps js on js.job_id = j.job_id
- outer apply (
- select top 1 instance_id, jh.run_status, jh.run_date, jh.run_time from msdb..sysjobhistory jh
- where jh.job_id=j.job_id and jh.step_id=0
- order by instance_id desc
- ) jh
- where 1=1
- and js.command like N'%xxxxxxxxxxxxxxxxx%'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement