How to Change the SQL Server Name after Renaming the Windows Host

,

When we change the name of the windows machine on whom the SQL Server is running, the SQL server name does not reflect this change. We need to manually add the new server name and remove the old server name.

Example

We have changed the windows machine name from Ahsi-PC to Shashank but when we look for the SQL Server name it will give the old windows machine name. You can see this in the image below. The new name is listed in Object Exporer, but the old name appears on the right as the result of the query.

To correct this, we need to first run sp_dropserver 'Old server Name' in the master database.

Next, we run sp_addserver 'New server name','local' in the master database. After running this, restart the SQL Server services.

Now check the new name of the instance by running select @@servername.

The SQL instance name has been changed and matches the windows name change.

The minimum rights required to perform this action are in the setupadmin server role.

Rate

3.85 (39)

Share

Share

Rate

3.85 (39)