bisonn icon

Untitled

bisonn | PRO | 12/09/19 08:01:16 AM UTC | 0 ⭐ | 6666 👁️ | Never ⏰ | []
T-SQL |

820 B

|

None

|

0 👍

/

0 👎

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%'

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎