with Test_Recursion(Id,ParentId)
AS
(
select Id,ParentId  from [V_KPI_DetailsActivities] where ParentId  = 4 --没有引用CTE自身必须放在第一个递归行之上
union all  --没有引用CTE自身的语句和第一个递归行之间必须用UNION ALL
select a.Id,a.ParentId from [V_KPI_DetailsActivities] as a join Test_Recursion as b on a.parentid=b.id--递归行
)
select * from Test_Recursion

相关文章:

  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2021-12-19
  • 2021-06-12
  • 2022-12-23
  • 2021-10-22
  • 2021-08-29
相关资源
相似解决方案