欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

sql server递归

程序员文章站 2022-05-08 11:21:51
with cte as ( select belongsAgent from [QPProxyDB].[dbo].[BS_ProxyInfo] where ProxyID = @ProxyID union all select a.ProxyID from [QPProxyDB].[dbo].[BS... ......
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