我只是在玩 cte 打印 1 到 10 或打印 12 个月
create table eventlist
(
id int identity(1,1) not null,
edate smalldatetime
)
select * from eventlist
insert into eventlist select '01/01/2012'
;with cte AS
(
select edate from eventlist
union all
select dateadd(M,1,edate) from cte where MONTH(edate)<12
)
select MONTH(edate), YEAR (edate) from cte
但突然间,我只是像这样将 cte 中的另一个联合所有部分组合在一起
;with cte AS
(
select edate from eventlist
union all
select dateadd(M,1,edate) from cte where MONTH(edate)<12
union all
select dateadd(Y,1,edate) from cte where YEAR(edate)<2013
)
select MONTH(edate), YEAR (edate) from cte
当我运行这个我会得到这个错误
声明终止。在语句完成之前,最大递归 100 已用完。
由于递归限制,我理解这个错误,但是
i just want to understand how will this recurssion will work ?