您的位置:首页 > 其它

使用游标更新表中数据

2007-08-24 00:46 417 查看
(注:其中RemoteServer为定义的一个链接服务器)
declare mycursor2 cursor forward_only static
for select ProductId,ProductName from RemoteServer.northwind.dbo.products
declare @pid1 int,@pid2 int,@pname1 nvarchar(40),@pname2 nvarchar(40)
open mycursor2
fetch next from mycursor2 into @pid2,@pname2
while @@fetch_status=0
begin
update products set productname=@pname2 where productid=@pid2
fetch next from mycursor2 into @pid2,@pname2
end
close mycursor2
deallocate mycursor2
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: