WITH TEMP ([ID], [PARENTID]) AS (SELECT UNIQUEID ,PID FROM [DBO].TB_DEPTINFO D WHERE PID = @ParentId UNION ALL SELECT UNIQUEID ,PID FROM [DBO].TB_DEPTINFO I INNER JOIN TEMP ON I.PID = TEMP.[ID]) SELECT * FROM TEMP
时间: 2024-10-22 07:47:12
WITH TEMP ([ID], [PARENTID]) AS (SELECT UNIQUEID ,PID FROM [DBO].TB_DEPTINFO D WHERE PID = @ParentId UNION ALL SELECT UNIQUEID ,PID FROM [DBO].TB_DEPTINFO I INNER JOIN TEMP ON I.PID = TEMP.[ID]) SELECT * FROM TEMP