--查找父,包括自己
CREATE
PROC [dbo].[usp_spGetParentsID] @InputID INT --@ParentID UNIQUEIDENTIFIER OUTPUT AS BEGIN DECLARE @strResult Nvarchar; set @strResult=''; with cte as ( select ID,ParentID from Zitian_Categories where id=@InputID union all select a.id,a.ParentID from Zitian_Categories a join cte b on a.id=b.parentid ) select CONVERT(NVARCHAR,[id]) from cte --SELECT @strResult=CONVERT(NVARCHAR,[id])+','+@strResult from cte --set @strResult=substring(@strResult,1,(len(@strResult)-1)) --print @strResult END

 

相关文章:

  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-11-15
猜你喜欢
  • 2021-10-30
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
相关资源
相似解决方案