码迷,mamicode.com
首页 > 数据库 > 详细

sql语句使用游标修改表中数据

时间:2016-08-04 14:39:56      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:

declare @a varchar(100),@b varchar(100)
declare user_cursor cursor for
select a,b from tableA tab 
open user_cursor
fetch next from user_cursor
into @a,@b
while @@fetch_status=0
begin
update tableA set a=@a where b=@b
fetch next from user_cursor
into @a,@b
end 
CLOSE user_cursor
DEALLOCATE user_cursor

 

sql语句使用游标修改表中数据

标签:

原文地址:http://www.cnblogs.com/ly77461/p/5736473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!