Table of Contents

List jobs using a history retention setting other than the default

This query lists all jobs that are configured to use a history retention setting other than the instance default setting, showing what the setting is for each job. The default setting is configured in Configuration>General Server Options.

select j.oid,g.name as 'Group',j.name as 'Job' ,j.historyRetentionLimit as 'Limit',
Setting = case j.historyretentionoptions
    when 0 then 'Default'
    when 1 then 'No Retention'
    when 2 then 'Days'
    when 3 then 'Executions'
    when 4 then 'Forever'
end 
from job j join jobGroup g on j.jobGroupOID=g.oid
where j.historyRetentionOptions<>0
order by g.name,j.name