Technical Article

Find unused jobs

,

Job list cluttered?
This script will return a list of jobs that either have not run in X months or where the next schedule run date is older than today.

Just run this against any server. Investigate if the job can be deleted. To be on the safe side, you can always script the job by: Right clicking the job / Script job as / Create to

SELECT@@SERVERNAME SvrName, J.Name, J.[Enabled], JA.LastRun, JA.NextRun, JV.[description], JC.Name JobCategory
FROMmsdb.dbo.sysjobs J
JOIN msdb.dbo.sysjobs_view JV
ON J.Job_ID = JV.Job_ID
JOIN
(
SELECTJob_ID, MAX(Last_Executed_Step_Date) LastRun, MAX(Next_Scheduled_Run_Date) NextRun
FROMmsdb.dbo.sysjobactivity 
GROUPBY Job_Id
) JA
ON J.Job_ID = JA.Job_ID
JOIN msdb.dbo.syscategories JC
ON J.Category_ID = JC.category_id
WHEREDATEDIFF(m, ISNULL(LastRun, '1900-01-01'), GETDATE()) > 12
OR NextRun < GETDATE()

Rate

1.8 (5)

You rated this post out of 5. Change rating

Share

Share

Rate

1.8 (5)

You rated this post out of 5. Change rating