SQL练习——使用游标给每条记录中的数量加50,并按行提取相关信息
发布时间
阅读量:
阅读量
题目:利用游标对商品表中的各项商品数量进行50的增量调整,并依次获取更新后的商品数据信息。
declare n cursor
scroll
for select 数量 from 商品
open n
declare @number char(20)
fetch first from n into @number --指定游标的起始位置
while @@FETCH_STATUS=0
begin
--print @number
update 商品 set 数量=@number+50 where current of n
fetch next from n into @number
--update 商品 set 数量=@number+50
----fetch next from n
end
close n
deallocate n
go
`
全部评论 (0)
还没有任何评论哟~
