sqlever 对查询出来的数据进行遍历

Posted 七分暖

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlever 对查询出来的数据进行遍历相关的知识,希望对你有一定的参考价值。

Declare   @row int,  --行记录数
@count int,--总记录数
@id int, --你需要的结果select @count=COUNT(1),@row =1 from  表名
 SELECT ROW_NUMBER() OVER (ORDER BY UserId ASC) rowid,* into #t from 表名while @row <= @count --循环开始 
BEGIN
select @id=rowid,@TopRealTimeXml=TopRealTimeXml,@userId=UserId from #t where rowid=@row --当前列的数据
--需要执行的代码 set @row=@row +1
END
drop table #t--记得删除零时表

 

以上是关于sqlever 对查询出来的数据进行遍历的主要内容,如果未能解决你的问题,请参考以下文章