SQL Server数据库实例名与服务器名不一致的解决办法
- --EXEC sp_addlinkedserver
- -- @server = \'PSHGQ\'
- --GO
- --select * from sys.servers
- --EXEC sp_dropserver \'PSHGQ\'
- --EXEC sp_addserver \'SUGON\', local
- --select @@servername
- --select serverproperty(\'servername\')
- use [数据库]
- go
- select @@servername
- select serverproperty(\'servername\')
- go
- ------
- IF serverproperty(\'servername\')<>@@servername
- BEGIN
- DECLARE @server SYSNAME
- SET @server=@@servername
- EXEC sp_dropserver @server=@server
- SET @server=cast(serverproperty(\'servername\') AS SYSNAME)
- EXEC sp_addserver @server=@server,@local=\'LOCAL\'
- END
- ELSE
- PRINT \'实例名与主机名一致,无需修改!\'