Posted on Leave a comment

@@SERVERNAME returns name of old server

— in the case where a server has been cloned or renamed 
— and @@SERVERNAME still returns name of old server

use master
go

SELECT @@SERVERNAME, SERVERPROPERTY(‘MachineName’)
GO

SELECT [server_id]
      ,[name]
      ,[product]
      ,[provider]
      ,[data_source]
  FROM [master].[sys].[servers]
GO

sp_dropserver ‘OLDSERVEROLDINSTANCE’;
GO
sp_addserver ‘NEWSERVERNEWINSTANCE’, local;
GO

— has been updated in servers table
SELECT [server_id]
      ,[name]
      ,[product]
      ,[provider]
      ,[data_source]
  FROM [master].[sys].[servers]
GO

— may need to restart instance 
— for it to take effect for @@SERVERNAME

SELECT @@SERVERNAME, SERVERPROPERTY(‘MachineName’)
GO

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.