Get the last 24 hour job record form msdb.dbo.sysjobhistory

前端 未结 3 864

I want write a query to get the last 24 hours worth of job record from the \"msdb.dbo.sysjobhistory\" table, but I can\'t get because I get the \"run_date\" and \"run_time\"

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-05 06:45

    For databases after 2000, there is a function in the msdb database you can call that will return datetime:

    msdb.dbo.agent_datetime(run_date, run_time) as 'RunDateTime'
    

    If you are using sql 2000, you can copy the source of that function from a later version and create it in your instance of 2000. I wish I could take credit for all of this, but I originally found it here: mssqltips.com

提交回复
热议问题