declare @foladID nvarchar(500) set @foladID='DCAE7E1B-266F-40B0-AA4B-97EBD334A25D'; with tab as( select * from Folders where id=@foladID union all select k.* from Folders k inner join tab c on k.id = c.Parentid ) select * into #tab from tab --不包括本身 update Folders set Folders.FolderCount=Folders.FolderCount+1 from #tab where Folders.Id=#tab.Id and Folders.Id!=@foladID drop table #tab
Trashed 能够换成临时表,因为个人数据是分红了2个表全部代码有点繁琐sql