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?

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top