SQLTeam.com | Weblogs | Forums

Renaming Server That Has a Named SQL Instance

hi experts,
After I rename this Windows 2019 VM, will I need to do anything for the named instance?

Yes - you need to drop the old server and add the new server in SQL:

1 Like

Thanks, @jeffw8713
• For a renamed computer that hosts a named instance of SQL Server, run the following procedures:
EXEC sp_dropserver '<old_name\instancename>';
EXEC sp_addserver '<new_name\instancename>', local;

Why is local necessary, what does it do? This is a named instance.

@jeffw8713 do you know if it matters whether the server/VM is renamed before or after I run the
sp_dropserver and sp_addserver statements?
Another team will rename the VM so I need to recommend the correct sequence.

I wouldn't change it in SQL Server until after the server has been renamed.

Thanks but doesn't the server rename require a reboot? After the reboot the SQL instance would not start (because I haven't yet ran drop server, add server). Am I wrong? I just need clarification as we plan to do this tonight.
Would this sequence work?

  1. rename the VM
  2. drop and add server name
  3. reboot server


It can be done after, SQL Server will startup after renaming the VM, but your steps should also work, either way.

1 Like

@jeffw8713 This is the sequence we used:

  1. renamed the VM/Server
  2. rebooted
  3. ran sp_dropserver and sp_addserver statements
  4. bounced SQL engine service
  5. tested connectivity to the newly renamed server

That worked perfectly. Thanks for your advice!

1 Like