sql server递归

ProxyID 父级

belongsAgent 子集

 

with cte as
(
select belongsAgent from [QPProxyDB].[dbo].[BS_ProxyInfo] where ProxyID = @ProxyID 
union all
select a.ProxyID from [QPProxyDB].[dbo].[BS_ProxyInfo] a join cte b on a.ProxyID = b.belongsAgent
)
select * from cte order by belongsAgent asc
You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图