我有大量记录的CTE查询。以前它工作正常。但是最近,它对某些成员抛出了错误
声明终止。在语句完成之前,最大递归100已用尽。
因此,我提出OPTION (maxrecursion 0)或接受OPTION (maxrecursion 32767)查询,因为我不想限制记录。但是,结果是查询需要永远加载。我该如何解决?
这是我的代码:
with cte as(
-- Anchor member definition
SELECT e.SponsorMemberID , e.MemberID, 1 AS Level
FROM tblMember AS e
where e.memberid = @MemberID
union all
-- Recursive member definition
select child.SponsorMemberID , child.MemberID, Level + 1
from tblMember child
join cte parent
on parent.MemberID = child.SponsorMemberID
)
-- Select the CTE result
Select distinct a.*
from cte a
option (maxrecursion 0)
江户川乱折腾
慕桂英3389331
相关分类