1 CREATE PROCEDURE [dbo].[GetTree] 
 2 @Id int
 3 AS
 4 BEGIN
 5     with cte as
 6     (
 7         select Id,Pid,Name,0 as lvl from Entity
 8         where Id = @Id
 9         union all
10         select e.Id,e.Pid,e.Name,lvl+1 from cte c inner join Entity e
11         on c.Id = e.Pid
12     )
13     select * from cte
14 END

 

相关文章:

  • 2022-12-23
  • 2022-01-17
  • 2021-06-28
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2021-11-13
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-11-12
相关资源
相似解决方案