Technical Article

Script to get details of enabled jobs

,

This script will give detials for all the enabled job including their steps/command/schedule.

SELECT b.name as job_name,c.Schedule,c.next_run_time
      ,step_name,subsystem,command,database_name 
 FROM msdb..sysjobsteps a
INNER JOIN (SELECT name,job_id 
                FROM msdb..sysjobs 
                WHERE enabled = 1)b 
      ON a.job_id =b.job_id 
INNER JOIN (SELECT job_id
                  ,(CASE WHEN freq_type = 4 THEN 'Daily' 
                         WHEN freq_type =16 THEN 'Monthly'
                         WHEN freq_type =8  THEN 'Weekly' 
                         END )as Schedule
                  ,left(right('000000'+convert(varchar,next_run_time),6),4) as next_run_time
              FROM msdb..sysjobschedules ) c 
     ON a.job_id =c.job_id

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating