SQL Server 2000 中 sp_addlinkedserver 的问题
我在从一台运行 SQL Server 2000 (A) 的服务器和另一台运行 SQL Server 2008 (B) 的服务器移动特定数据时遇到了一些问题。我正在根据客户规范编写一个脚本,该脚本将在 A 上执行,用数据填充 B 中的表。但是,我似乎无法使服务器链接正常工作。
-- Bunch of declarations here
EXEC sp_addlinkedserver @server = @ServerName,
@srvproduct = @ServerProduct,
@provider = @ProviderString,
@datasrc = @RemoteHost
-- Data migration stuff here
EXEC sp_dropserver @ServerName
现在,如果我完整地运行脚本,我会收到一条错误消息:
消息 7202,级别 11,状态 2,第 55 行 找不到服务器“remoteServer” 在系统服务器中。执行 sp_addlinkedserver 添加服务器 到系统服务器。
但是,如果我仅突出显示 sp_addlinkedserver 部分并执行它,则不会出现错误,我可以突出显示脚本的其余部分并运行它。我在这里缺少什么?
请帮忙!
附言。如果备份恢复是一个选项,我早就这么做了。
I'm having a bit of a problem with moving specific data from one server running SQL Server 2000 (A) and another running SQL Server 2008 (B). I'm writing a script according to customer specifications which is to be executed on A, populating tables in B with data. However, I can't seem to get the server link to work.
-- Bunch of declarations here
EXEC sp_addlinkedserver @server = @ServerName,
@srvproduct = @ServerProduct,
@provider = @ProviderString,
@datasrc = @RemoteHost
-- Data migration stuff here
EXEC sp_dropserver @ServerName
Now if I run the script in its entirety I get an error saying:
Msg 7202, Level 11, State 2, Line 55
Could not find server 'remoteServer'
in sysservers. Execute
sp_addlinkedserver to add the server
to sysservers.
However, if I highlight only the sp_addlinkedserver
part and execute that, there is no error and I can highlight the rest of the script and run it. What am I missing here?
Please help!
PS. If backup-restore was an option, I would have done that already.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于 SQL Server 在运行代码之前尝试验证代码。为了证明这一点,请尝试将命令之一放入 EXEC() 中。尝试在 sp_addlinkedserver 命令后放置 GO。
The problem is that SQL Server is trying to validate the code before it runs it. To show that, try putting one of your commands in EXEC(). Try putting a GO after the sp_addlinkedserver command.