You can get a job list on SQLServer as a table by this SQL.
SELECT TOP 100 PERCENT t1.name ,t2.step_id ,t2.step_name ,t2.command ,t4.plan_name ,t3.enabled ,CAST(LEFT(t3.active_start_date,4) + '/' + SUBSTRING(CAST(t3.active_start_date AS varchar), 5,2) + '/' + RIGHT(t3.active_start_date,2) AS datetime) AS active_start_date ,t3.active_start_time ,CAST(LEFT(t3.next_run_date, 4) + '/' + SUBSTRING(CAST(t3.next_run_date AS varchar), 5,2) + '/' + RIGHT(t3.next_run_date,2) AS datetime) AS next_run_date ,t3.next_run_time FROM dbo.sysjobs t1 INNER JOIN dbo.sysjobsteps t2 ON t1.job_id = t2.job_id INNER JOIN dbo.sysjobschedules t3 ON t1.job_id = t3.job_id LEFT OUTER JOIN dbo.sysdbmaintplans t4 ON SUBSTRING(t2.command,42,36) = CAST(t4.plan_id AS char(36)) ORDER BY t1.name
No comments:
Post a Comment