Vous mettez probablement l'option au mauvais endroit. Il doit être après le où
WITH allDays AS (
SELECT @DateEarly AS date
UNION ALL
SELECT DATEADD(dd, 1, date) as date
FROM allDays s
WHERE DATEADD(dd, 1, date) <= @DateLate
)
SELECT *
from allDays
where dbo.isFestivo(date)>0
option (maxrecursion 200);
Mais essayez ceci à la place. Ce sera plus rapide...
select DATEADD(d, number, @dateearly) as [date]
from master..spt_values
where type='p'
and number<=datediff(d,@dateearly,@datelate)
and dbo.isFestivo(date)>0