SELECT
-- job.job_id,
-- notify_level_email,
name,
-- Right('00000000' + Cast(steps.last_run_time as varchar),6) as time,--hhmmss
left(substring('000000',1,6-len(next_run_time))+Convert(nchar,next_run_time),2)+':'+substring(substring('000000',1,6-len(next_run_time))+Convert(nchar,next_run_time),3,2)+':'+right(next_run_time,2) as RUNTIME,
enabled,
description,
step_name,
command,
server,
database_name
FROM
msdb.dbo.sysjobs job
INNER JOIN
msdb.dbo.sysjobsteps steps ON job.job_id = steps.job_id
left join msdb.dbo.sysjobschedules as s on job.job_id = s.job_id
WHERE
job.enabled = 1 -- remove this if you wish to return all jobs
order by next_run_time asc
沒有留言:
張貼留言