• Welsh Corgi (3/31/2013)


    Lynn Pettis (3/31/2013)


    Perhaps something more like this:

    SELECT

    j.job_id,

    s.srvname,

    j.name,

    js.step_id,

    js.command,

    j.enabled ,

    js.last_run_date,

    js.last_Run_Time,

    js.last_run_duration,

    msdb.dbo.Agent_datetime(js.last_Run_Date, js.last_Run_Time) AS Run_Datetime,

    dateadd(second, ((js.last_run_duration / 10000) * 3600) + (((js.last_run_duration / 100) % 60) * 60) + (js.last_run_duration % 60), msdb.dbo.Agent_datetime(js.last_Run_Date, js.last_Run_Time)) as EndRunDate

    FROM

    dbo.sysjobs j

    JOIN dbo.sysjobsteps js

    ONjs.job_id = j.job_id

    JOIN master.dbo.sysservers s

    ONs.srvid = j.originating_server_id

    WHERE

    j.name = 'TestJob';

    If you execute the code you will get the following error:

    Msg 241, Level 16, State 1, Line 2

    Conversion failed when converting date and/or time from character string.

    Thanks for you reply.

    What job did you create?

    What was in the execute of the step(s)?

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/