• Leo,

    good article.  However, there is an issue with your use of the sysjobhistory table.  You mention, near the end of your article, that if we want to check on jobs that are still running we should change the line:

    and soh.run_status = 1 -- successful jobs

    with line

    and ( soh.run_status = 1 or soh.run_status = 4 ) -- successful and in progress jobs

    However, the sysjobhistory table does not get populated by history information until the job completes, which means you cannot check for jobs that are still in progress.

    I would suggest using master..xp_sqlagent_enum_jobs instead, which will always give you a more up to date view of what is happening to your jobs.

    Regards,