Question

I have a SQL Server job that runs biweekly on Monday. I also have a table with a list of holiday dates. I want to be able to skip running my job on any Monday that is a holiday and instead run that iteration of the job the next day.

Any ideas on how to do this?

Was it helpful?

Solution

Set up the job on Monday and Tuesday.

For the job, start with the logic:

if (cast(getdate() as date) in (select days from holidaytable) and
    datename(weekday, getdate()) = 'Monday'
   ) or
   (cast(getdate()-1 as date) not in (select days from holidaytable) and
    datename(weekday, getdate()) = 'Tuesday'
   )
begin
    don't run the job now (whatever you want to do to log that)
end;
rest of the code for the job
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top