CTE的递归次数限制在32767之下  对这个数字我不太明白   是这个递归只能做32767次也就是查出32767条数据(姑且这么说),还是不论数据多少 只能 向下或向上深入32767层?

解决方案 »

  1.   

    和查询出来的数据多少没有关系。
    可能是最多只能有32767个cte吧。
      

  2.   

    循环次数吧,
    for i := 1 to 32767 do
    begin
    end;
      

  3.   

    每个CTE是有默认的递归层数的--100次.如果你想设置,甚至取消这个限制,可以这样
    ;with ctes as
    (
     select child from #testt where pid=@pid
     union all
     select a.child from #testt a join ctes b on a.pid=b.child
    )
    select * from ctes option (maxrecursion 1000)
    这里的1000就是嵌套循环的次数上限;如果你想取消限制,设置其为0.