declare hh cursor scroll for select ee from qq for read only
open hh declare @ee int, @i int set @i=1 fetch next from hh into @ee while (@@FETCH_STATUS<>-1) begin if(@i=3) begin print @ee set @i=0 end fetch next from hh into @ee set @i=@i+1 end
close hh
deallocate hh
declare ss cursor scroll for select cc,ee from qq join zz on qq.ww=zz.ww for update open ss declare @ee int,@cc int fetch next from ss into @cc,@ee while (@@FETCH_STATUS<>-1) begin if(@ee<400 ) begin print @cc update qq set ee=ee+1000000 where current of ss end fetch next from ss into @cc,@ee end close ss deallocate ss