with cte as 
(
    select ClassID,ClassName,ParentID,ParentPath,CAST(row_number() over(order by ClassID) as varbinary(max)) as sort
    from dc_SysItemsClass
    where ClassID = 1
    
    union all
    
    select a.ClassID,a.ClassName,a.ParentID,a.ParentPath,sort+CAST(row_number() over(partition by a.ParentID order by a.ClassID) as varbinary(max))
    from  dc_SysItemsClass a
    inner join cte b
    ON a.ParentID = b.ClassID 
)
select ClassID,ClassName,ParentID,ParentPath,sort
from  cte 
order by sort

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-11-13
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案