Excluding Job Execution On Holidays

  • Hi All,

    I have a job scheduled to run daily once at 11:00 AM. Now I have a requirement in which that job should not run on holidays i.e. on particular dates. Please assist me finding solution for the same.

    Thanks

  • I dont think this feature is available while scheduling your job. You'll have to manually disable it/enable it OR you can create a Holidays table containing holiday dates and query this table prior to running the job. if the date matches, quit the job or else continue with execution.



    Pradeep Singh

  • I'll second that. It also makes adding "snow" and "emergency" days easy.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I've typically just had a holiday table since each business handles them differently. It will allow you to easily query for any off days, as Jeff mentioned, that are specific to your business.

  • HI All ,

    Thanks for your reply.

    Can you please assist me with the steps to achieve this solution...

  • HI All ,

    Thanks for your reply.

    Can you please assist me with the steps to achieve this solution...

  • -- Create the Holiday Table

    create table tblHolidays

    (

    id int identity(1,1),

    Holiday datetime

    )

    -- Insert test Holiday dates

    Insert Into tblHolidays(holiday)

    select (getdate()-1)

    Union all

    select (getdate()+2)

    Union all

    select (getdate()+1)

    Union all

    select (getdate()+10)

    -- Insert this as a part of job step

    if not exists(

    select 1 from tblHolidays where convert(varchar,Holiday,112)=convert(varchar,getdate(),112)

    )

    -- Your commands here

    Exec Mysp



    Pradeep Singh

  • Thanks

Viewing 8 posts - 1 through 7 (of 7 total)

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