How could you know which jobs are configured on the server


How could you know which jobs are configured on the server and what is the frequency of Job? Below script is just workaround which will help you to get this answer…

SELECT      J.name, J.Enabled, J.Description,
            CASE S.freq_type 
                  WHEN 1 THEN 'Once'
                  WHEN 4 THEN 'Daily'
                  WHEN 8 THEN 'Weekly'
                  WHEN 16 THEN 'Monthly'
                  WHEN 32 THEN 'Monthly, relative to freq_interval'
                  WHEN 64 THEN 'Run when SQLServerAgent service starts'
                  WHEN 128 THEN 'Run when the computer is idle'
            END
FROM  msdb..sysJobs J
JOIN  msdb..sysjobschedules JS ON J.job_id = JS.Job_id
JOIN  msdb..sysschedules S ON JS.Schedule_id = S.Schedule_id
---Search Criteria to see only Active Jobs within the Time Frame
WHERE (000000 BETWEEN S.active_start_time AND S.active_end_time)
            OR (060000 BETWEEN S.active_start_time AND S.active_end_time)
            AND J.enabled = 1
GO
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s