--获取当前及以下部门
Create proc GetCurrentAndUnderOrg
@orgId int
as
begin
WITH cte
AS
(
SELECT * ,0 AS level FROM Static_Organ WHERE OrganID=@orgId
UNION ALL
SELECT g.*,level+1 FROM Static_Organ g INNER JOIN cte
ON g.ParentOrgan=cte.OrganID
)
SELECT * FROM cte
end
编辑器加载中...