游标 处女作
由于触发器的原因,所以更新数据的时候经常不能使用直接update来修复数据。所以试着去用游标来更新
代码
declare upduser scroll cursor
for
select aopp_userid from aopportunity
where aopp_userid <> aopp_createdby
and aopp_status ='ccfollowup'
and aopp_deleted is null
and aopp_userid is not null
for update
open upduser
declare @aopp_userid int
fetch from upduser into @aopp_userid
while @@fetch_status = 0
begin
if @aopp_userid is not null
--print @aopp_userid
update aopportunity set aopp_createdby = @aopp_userid,aopp_contractcounselor = @aopp_userid
where current of upduser
fetch from upduser into @aopp_userid
end
close upduser
deallocate upduser
作者:Novus
出处:http://www.cnblogs.com/novus/
本文版权归作者和博客园共有,欢迎任何形式的转载,但请务必注明出处。