BEGIN ;
WITH Corps AS
(
SELECT StruID,
StruType
FROM OperAllowDB.dbo.TCorpStructure
WHERE ParentStruID = @StruID
UNION ALL
SELECT A.StruID,
A.StruType
FROM OperAllowDB.dbo.TCorpStructure A
JOIN Corps B ON A.ParentStruID = B.StruID
)
--返回自己和所有的子节点
SELECT StruID
FROM Corps
WHERE StruType = 'D' ;
END ;