sql 遍历结果集

it2022-05-05  131

declare @temp table ( [id] int IDENTITY(1,1), [Name] varchar(10) ) --select * from @temp declare @tempId int,@tempName varchar(10) insert into @temp values('a') insert into @temp values('b') insert into @temp values('c') insert into @temp values('d') insert into @temp values('e') --select * from @temp WHILE EXISTS(select [id] from @temp) begin SET ROWCOUNT 1 select @tempId = [id],@tempName=[Name] from @temp SET ROWCOUNT 0 delete from @temp where [id] = @tempId print 'Name:----'+@tempName end

  

转载于:https://www.cnblogs.com/sishahu/p/4935304.html

相关资源:SQLSERVER遍历数据

最新回复(0)