How to rename instance of SQL Server after a computer rename

For a renamed computer that hosts a default instance of SQL Server, run the following procedures:

sp_dropserver <old_name>;
GO
sp_addserver <new_name>, local;
GO

Restart the instance of SQL Server.

For a renamed computer that hosts a named instance of SQL Server, run the following procedures:

sp_dropserver <old_name\instancename>;
GO
sp_addserver <new_name\instancename>, local;
GO

Restart the instance of SQL Server.

To verify that the renaming operation has completed successfully select information from either @@SERVERNAME or sys.servers. The @@SERVERNAME function will return the new name, and the sys.servers table will show the new name. The following example shows the use of @@SERVERNAME.

SELECT @@SERVERNAME AS ‘Server Name';

 

This entry was posted in SQL and tagged . Bookmark the permalink.