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

浙公网安备 33010602011771号