主机更名带来的问题

[TOC]

解决主机更名导致的不一致问题

SELECT @@ServerName,SERVERPROPERTY('ServerName')
IF @@SERVERNAME <> SERVERPROPERTY('ServerName') 
BEGIN 
    DECLARE @srvname sysname 
    SET @srvname = @@SERVERNAME 
    EXEC sp_dropserver @server = @srvname 
    SET @srvname = CAST( SERVERPROPERTY('ServerName') as sysname) 
    EXEC sp_addserver @server = @srvname , @local = 'LOCAL' 
END

注意,必须重启 SQL Server 服务才会生效

Copyright © www.sqlfans.cn 2024 All Right Reserved更新时间: 2022-01-14 17:29:54

results matching ""

    No results matching ""