Pergunta

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?

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top