• The code below will give a list of jobs that have been running over ten minutes (can be anything you want).

    Remember to exclude jobs you expect to run long (e.g. REPL jobs). You can exclude by job category

    declare

    @session_id int,

    @minutesLmit int

    set @minutesLmit = -10

    select

    @session_id = max(session_id)

    from

    [msdb].[dbo].[sysjobactivity]

    select

    SERVER = @@servername,

    jo.name,

    ja.start_execution_date

    from

    [msdb].[dbo].[sysjobactivity] ja

    JOIN

    select * from [msdb].[dbo].[sysjobs] jo ON ja.job_id = jo.job_id

    where

    ja.session_id = @session_id

    AND start_execution_date is not null

    AND start_execution_date < dateadd(mi,@minutesLmit,getdate())

    AND stop_execution_date is NULL