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--删除