SQLServer数据库实例名与服务器名不一致的解决办法
时间:2021-07-01 10:21:17
帮助过:7人阅读
SQL Server数据库实例名与服务器名不一致的解决办法 1.--EXEC sp_addlinkedserver 2.-- @server = PSHGQ 3.--GO 4.--select * from sys.servers 5.--EXEC sp_dropserver PSHGQ 6.--EXEC sp_addserver SUGON, local 7.--select @@servername 8.--select server
SQL Server数据库实例名与服务器名不一致的解决办法
1.--EXEC sp_addlinkedserver
2.-- @server = 'PSHGQ' 3.--GO 4.--select * from sys.servers 5.--EXEC sp_dropserver 'PSHGQ' 6.--EXEC sp_addserver 'SUGON', local 7.--select @@servername 8.--select serverproperty('servername') 9.
10.
11.
12.use [数据库]
13.go
14.select @@servername 15.select serverproperty('servername') 16.go
17.------ 18.IF serverproperty('servername')<>@@servername 19.BEGIN 20.DECLARE @server SYSNAME 21.SET @server=@@servername 22.EXEC sp_dropserver @server=@server 23.SET @server=cast(serverproperty('servername') AS SYSNAME) 24.EXEC sp_addserver @server=@server,@local='LOCAL' 25.END 26.ELSE 27.PRINT '实例名与主机名一致,无需修改!'