How to Change SQL Server Name after Windows Hostname Change

You have changed the Windows hostname and you need to perform the changes for the Microsoft SQL Server as well.

The steps are taken using the Microsoft Management Studio.

Note: You need to reboot your Windows operating system after the Windows hostname change.

Open the new query and execute the following commands,

  • Obtain the old SQL Server name.
SELECT @@SERVERNAME AS 'Old Server Name'
  • Obtain the current SQL Server name.
EXEC xp_getnetname
  • Drop the old SQL Server name.
EXEC sp_dropserver '[VALUE-FROM-OLD-Server-Name]'; 
go
  • Register the new SQL Server name.
EXEC sp_addserver '[VALUE-FROM-XP_GETNETNAME]', local;  
go
  • Restart SQL server services and vefiry with below 2 command. The value returned should be the same from both commands.
SELECT @@SERVERNAME AS 'Old Server Name'

EXEC xp_getnetname

You May Also Like

Leave a Reply?