数据库服务器改名后保证SQL 作业及复制可用

遇到先装SQL Server,后改计算机名,做作业的自动执行、服务器复制时遇到错误一样。按以下步骤操作可以修复:

方法一、
1、先查看计算机名:

SELECT @@SERVERNAME As [@@SERVERNAME],
CAST(SERVERPROPERTY('MACHINENAME') AS VARCHAR(128)) + COALESCE('/' + CAST(SERVERPROPERTY('INSTANCENAME') AS VARCHAR(128)), '') As RealInstanceName

 

2、直接执行下面语句:
DECLARE @InternalInstanceName sysname;
DECLARE @MachineInstanceName sysname;

SELECT @InternalInstanceName = @@SERVERNAME, @MachineInstanceName = CAST(SERVERPROPERTY('MACHINENAME') AS VARCHAR(128)) + COALESCE('/' + CAST(SERVERPROPERTY('INSTANCENAME') AS VARCHAR(128)), '');

IF @InternalInstanceName <> @MachineInstanceName
begin
-- Rename the instance
EXEC sp_dropserver @InternalInstanceName;
EXEC sp_addserver @MachineInstanceName, 'LOCAL'
END

 

3、重启SQL Server服务

 

方法二、

你可能感兴趣的:(数据库服务器改名后保证SQL 作业及复制可用)