SQL用row_number进行高速循环

SQL用row_number进行循环查询

declare @count int=0,@R int=0
select row_number()over(order by RoomID) as R,* into #t from Room where RMClassID='2'
select @count=COUNT(0) from #t
while(@R<@count)
begin
   set  @R=@R+1
   insert into RM select * from #t where R=@R
end
drop table #t

原文地址:https://www.cnblogs.com/xytmj/p/xytmj_SQL_row_number_for.html