没有递归 CTE 使用如何获得低于预期的结果..
DECLARE @temp TABLE
(
ParentCode VARCHAR (100)
, ChildCode VARCHAR(100)
)
INSERT INTO @temp
SELECT '101', '102' UNION ALL
SELECT '102', '101' UNION ALL
SELECT '103', '104' UNION ALL
SELECT '104', '103' UNION ALL
SELECT '105', '106' UNION ALL
SELECT '106', '105'
SELECT * FROM @temp
输出:
ParentCode
101
103
105