博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

怎样使用游标

Posted on 2006-03-14 20:52  joanjett  阅读(175)  评论(0)    收藏  举报
declare @c_bid int,@c_aa int
declare cur cursor for select * from t2
open cur
fetch next from cur into @c_bid,@c_aa
while @@fetch_status = 0
begin
 update t1 set aa = @c_aa where bid = @c_bid
 fetch next from cur into @c_bid,@c_aa
end
close cur
deallocate  cur