문제

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