Home Forums SQL Server 7,2000 T-SQL T-SQL statement to return SQL Job Last Run Date RE: T-SQL statement to return SQL Job Last Run Date

  • Bringing a thread back from the dead but to help people that stumble accross this page in the future

    you could use the sql system function msdb.dbo.agent_datetime(run_date, run_time) to calculate the date time value from the run_date and run_time integer values stored in the msdb.dbo.sysjobhistory table.

    e.g.

    Select J.name,MAX(msdb.dbo.agent_datetime(run_date, run_time)) as 'LastLogRun'

    FROM msdb.dbo.sysjobhistory H

    Inner join msdb.dbo.sysjobs J ON H.job_id = J.job_id

    where step_id = 0

    GROUP BY J.name