当前位置: 代码迷 >> Sql Server >> 记录查询有关问题.
  详细解决方案

记录查询有关问题.

热度:65   发布时间:2016-04-27 18:57:52.0
记录查询问题..
比如有一个表中有10万条记录,按照某个条件查询(如日期)时能得到一些记录,   我要对每个查询到的记录做操作,该如何处理呢,可以不用建临时表吗??是不是用while循环??

------解决方案--------------------
declare tb cursor for select name,startno,endno from from tablea where .....

open tb
fetch next from tb into ....
while @@fetch_status=0
begin
......

fetch next from tb into ...
end
close tb
deallocate tb

------解决方案--------------------
用游标吧,但是效率低
  相关解决方案