Scorpio05

;with a as(
 select ID = 1
 union all
 select ID + 1 from a
 where ID < 50
)
select *From a

OPTION (MAXRECURSION 0)

结果是50行连续的数字 option为无限制的写法,否则只能递归100次

;with a as (

select id form temp1 where id =#id

union all

select t1.id from  a,temp1 t1

where t1.fatherid = a.id)

select * from a

OPTION (MAXRECURSION 0)

数据表中ID与FatherID 的递归写法

 

分类:

技术点:

相关文章:

  • 2021-08-31
  • 2022-01-09
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-07-15
  • 2021-11-16
  • 2021-11-22
相关资源
相似解决方案