gpt4 book ai didi

sql-server - 重命名 SQL Server 主机后更新 sys.servers

转载 作者:行者123 更新时间:2023-12-01 06:17:47 30 4
gpt4 key购买 nike

我即将将我的 SQL Server 2012 实例升级到 SQL Server 2014。

我已经克隆了主机 Windows VM 并将其重命名为 foo-2012foo-2014 .
重新启动时,SQL Server 实例注意到它更新了自己的名称,因此我现在可以以 foo-2014 的身份登录它。 .都好。

不幸的是 sys.servers 中的(单个)条目还在foo-2012这意味着运行

SELECT * 
FROM [foo-2012].[barDB].[dbo].tFooBarTable

失败:

Could not find server 'RW-DB-2014' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.



美好的。

我跑 EXEC sp_addlinkedserver 'foo-2014', 'SQL Server'并获得一个条目。

但现在新条目有 isLinked=1 (而现有条目具有 isLinked=0 )。

Documentation表明此设置很重要(特别是对于我的应用程序,它对 Distr.Trans. 有很强的意见。:()

我无法直接编辑/添加/修改 sys.servers。任何这样做的尝试都会给出:

Ad hoc updates to system catalogs are not allowed.



我删除了成功的新条目( EXEC sp_dropserver 'foo-2014' ),并尝试使用 EXEC sp_addserver 'foo-2014', 'local'哪个报道

The server 'foo-2014' already exists



立即重新运行 drop 然后报告

The server 'RW-DB-2014' does not exist. Use sp_helpserver to show available servers.



我该如何解决?

最佳答案

您需要先删除旧服务器 foo-2012以便您在 sys.servers 中没有行,然后添加 'local' :

EXEC sp_dropserver 'foo-2012';
GO
EXEC sp_addserver 'foo-2014', 'local';
GO

然后您需要重新启动 MSSQLSERVER 服务以使更改生效,如 sp_addserver 的文档所述。 :

The local definition takes effect only after the Database Engine is restarted.

关于sql-server - 重命名 SQL Server 主机后更新 sys.servers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39637577/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com