sql 递归函数的用法

sql 递归函数使用 

SQL with as

 

示例:      

select * into #temp from Com_Structure a inner join Com_StructureType c on a.Com_SructureTypeID=c.Com_StructureTypeID where c.Type=1;
with cte as
(
select Com_StructureId from #temp where Com_StructureID=@Com_StructureId
union all
select a.Com_StructureId from #temp as a,cte as b where a.ParentStructureID=b.Com_StructureID
)
select * from cte

posted @ 2016-12-16 16:59  飞刀软件  阅读(846)  评论(0)    收藏  举报