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

posted @ 2013-08-01 20:56  下雨天的马甲  阅读(304)  评论(0编辑  收藏  举报