sql2005的一个递归应用

with ColumnCTE ( Organizationid)
as
(
select Organizationid from BasOrganization where Organizationid = '0cc7188e-fd61-410c-82d3-f02a4acf78df'
union all select tt.Organizationid from BasOrganization tt join ColumnCTE cte on tt.parentid = cte.Organizationid
)
select emsPort.PortID from ColumnCTE left outer join emsPort on emsPort.PortRelatedOrgID
= Organizationid  option(maxrecursion 0
posted @ 2009-06-27 16:46  goldkevin  阅读(146)  评论(0编辑  收藏  举报