Set job to NOT run on Holiday Mondays?

  • I have a job that runs on 10:00AM every Monday. Is there a way to set it up so it does not run on Holidays that fall on Mondays?

    Thanks for any help.

  • Only way I know is to use a Calendar table that is setup to tell you what days are holidaies, and then code the first step in the job to determine if it should continue or exit.

  • How does this code look? I created a table JobrunCal with the dates of the Monday holidays.

    DECLARE @countVar int

    set @countVar=1

    While @countVar=1

    begin

    if getdate() in (select * from JobrunCal)

    break

    else

    --the Job Code would run here in place of this query

    select * from jobruncal where date = '4/21/2012'

    set @countVar=0

    end

  • djustice 20821 (4/20/2012)


    How does this code look? I created a table JobrunCal with the dates of the Monday holidays.

    DECLARE @countVar int

    set @countVar=1

    While @countVar=1

    begin

    if getdate() in (select * from JobrunCal)

    break

    else

    --the Job Code would run here in place of this query

    select * from jobruncal where date = '4/21/2012'

    set @countVar=0

    end

    How about:

    if not exists(select 1 from jobruncal jrc where jrc.date = dateadd(dd, datediff(dd, 0, getdate()), 0))

    begin

    --your code to run

    end

  • If I'm looking at it right, this eliminates the need to set a variable and tell it to BREAK. It just doesn't run if the date is not in the table?

    Definitely seems more efficient. Thanks!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply