sqlserver 循环 + 递归 修改 末节点 标识
DECLARE @cnt INT = 0; WHILE @cnt < 27 BEGIN SET @cnt = @cnt + 1; PRINT @cnt; with temp (id,[Name],ParentCategriesID)as ( select id,[Name],ParentCategriesID from Categories where id=27 union all select a.id,a.[Name],a.ParentCategriesID from Categories a inner join temp on a.ParentCategriesID = temp.[id] ), lastNode as( select id from temp where id not in (select ParentCategriesID from Categories ) ) update Categories set HasNext=0 where id in (select * from lastNode) END
讓眾人的薪枝構起這團熱情的火焰