Ubah
select 1 as counter, @maxDate as Date
ke
select 1 as counter, DATEADD(day,1,@maxDate) as Date
Untuk membuatnya lebih sederhana, ubah CTE
;with GetDates As
(
select DATEADD(day,1,@maxDate) as TheDate
UNION ALL
select DATEADD(day,1, TheDate) from GetDates
where TheDate < @curDate
)
...