Home Forums SQL Server 2008 SQL Server Newbies SQL Agent job to only mail when having failed more than X times in a timeperiod RE: SQL Agent job to only mail when having failed more than X times in a timeperiod

  • tommy 28778 (7/25/2014)


    I could do it so job A, writes to a table everytime it completes, and then have job B check against the table to see if it succeeded, but this seems like a poor way of managing this issue.

    You DO need to setup an additional job to check/count the number of failed job-runs. But you do NOT need to write the results of the initial job to a table. You can just let the additional job query the [msdb]..[sysjobhistory] table and filter on job_id, run_date, run_time and run_status.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **