当前位置: 代码迷 >> Sql Server >> sqlserver2008中游标有关问题,执行后一个多小时都不显示结果,13000条数据,请各位大神帮忙看上!
  详细解决方案

sqlserver2008中游标有关问题,执行后一个多小时都不显示结果,13000条数据,请各位大神帮忙看上!

热度:27   发布时间:2016-04-27 11:08:59.0
sqlserver2008中游标问题,执行后一个多小时都不显示结果,13000条数据,请各位大神帮忙看下!急!!!
alter proc youbiao_1 
as
begin
declare @id int
 declare demo cursor for select resinterview.resInterviewId from resource,resinterview where resource.email=resinterview.email and resource.email!='' and resinterview.email!=''
 open demo
 fetch demo into @id
 while @@FETCH_STATUS=0
 begin
 update resource set [email protected] where resourceId=(select resourceId from resinterview where [email protected])

 end
 
 close demo
 end

------解决方案--------------------
标准游标写法:
SQL code
declare @rid intdeclare @times intdeclare fetch_id cursor for select RP_ID, times from RP_RegulationPlan --声明游标open fetch_id--打开fetch fetch_id into @rid,@timeswhile @@fetch_status=0begin    --这里写你要执行的语句    fetch next from fetch_id into @rid,@timesendclose fetch_id--关闭deallocate fetch_id--删除
  相关解决方案