哪位大侠帮忙看下下面这段语句的问题,执行后错误提示“语句被终止。完成执行语句前已用完最大递归 100” USE AdventureWorks; GO --Creates an infinite loop WITH cte (EmployeeID, ManagerID, Title) as ( SELECT EmployeeID, ManagerID, Title FROM HumanResources.Employee WHERE ManagerID IS NOT NULL UNION ALL SELECT cte.EmployeeID, cte.ManagerID, cte.Title FROM cte JOIN HumanResources.Employee AS e ON cte.ManagerID = e.EmployeeID ) --Uses MAXRECURSION to limit the recursive levels to 2 SELECT EmployeeID, ManagerID, Title FROM cte OPTION (MAXRECURSION 2); GO
--Creates an infinite loop WITH cte (EmployeeID, ManagerID, Title,lev) as ( SELECT EmployeeID, ManagerID, Title,lev=1 FROM HumanResources.Employee WHERE ManagerID IS NOT NULL UNION ALL SELECT cte.EmployeeID, cte.ManagerID, cte.Title,cte.lev+1 FROM cte JOIN HumanResources.Employee AS e ON cte.ManagerID = e.EmployeeID where cte.lev<3 ) --Uses MAXRECURSION to limit the recursive levels to 2 SELECT EmployeeID, ManagerID, Title FROM cte; GO