Renaming SQL Server to match your new computer name

Renaming SQL Server to match your new computer name

Renaming SQL Server to match your new computer name

IMPORTANT: 

**Please note this is not something covered under the Software Connection support plan. This is an external SQL server support issue that you may need to contact an outside PC technician to help you resolve. Our recommendation is to never change your host computers name after you have installed an SQL server instance as renaming the computer when running an SQL instance will always cause connections to the database to fail as they are all looking for the old name. If you require our support for an issue caused by renaming a host computer, we will advise you to name the computer back to the name it was previously and reboot to solve the issue. Again, the below is if you must keep the new name and want to attempt renaming the SQL server name on your own or with an outside PC technician’s help. 


 

From Microsoft: 

 

When you change the name of the computer that is running SQL Server, the new name is recognized during SQL Server startup. You do not have to run Setup again to reset the computer name. Instead, use the following steps to update system metadata that is stored in sys.servers and reported by the system function @@SERVERNAME. Update system metadata to reflect computer name changes for remote connections and applications that use @@SERVERNAME, or that query the server name from sys.servers.

The following steps cannot be used to rename an instance of SQL Server. They can be used only to rename the part of the instance name that corresponds to the computer name. For example, you can change a computer named MB1 that hosts an instance of SQL Server named Instance1 to another name, such as MB2. However, the instance part of the name, Instance1, will remain unchanged. In this example, the \\ComputerName\InstanceName would be changed from \\MB1\Instance1 to \\MB2\Instance1.



You can connect to SQL Server by using the new computer name after you have restarted SQL Server. To ensure that @@SERVERNAME returns the updated name of the local server instance, you should manually run the following procedure that applies to your scenario. The procedure you use depends on whether you are updating a computer that hosts a default or named instance of SQL Server.

Rename a computer that hosts a stand-alone instance of SQL Server

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

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

Restart the instance of SQL Server.
 

  • For a renamed computer that hosts a named instance of SQL Server, like KC's WKENNEL, run the following procedures:

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

Restart the instance of SQL Server.

After the Renaming Operation

After a computer has been renamed, any connections that used the old computer name must connect by using the new name.

Verify renaming operation

  • 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';  

Additional considerations

Remote Logins - If the computer has any remote logins, running sp_dropserver might generate an error similar to the following:

Server: Msg 15190, Level 16, State 1, Procedure sp_dropserver, Line 44 There are still remote logins for the server 'SERVER1'.

To resolve the error, you must drop remote logins for this server.

Drop remote logins

  • For a default instance, run the following procedure:

EXEC sp_dropremotelogin old_name;   GO  

  • For a named instance, run the following procedure:

EXEC sp_dropremotelogin old_name\instancename;  GO

    • Related Articles

    • Installing Kennel Connection 7 & SQL Server

      Installing Kennel Connection 7 & SQL Server Welcome to the installation guide for Kennel Connection 7.  Kennel Connection 7 is compatible with Windows 7 or higher operating systems.  Windows 10 is recommended.  Important:  If you are installing ...
    • SQL Server 2014 Express Setup Guide

      SQL Server 2014 Express Setup Guide SQL Server 2014 Express is a free download, available from Microsoft. This article will guide you through the process of acquiring, installing and configuring SQL Server 2014 Express so that you can use it with ...
    • Installing KC7 with an already existing version of SQL

      Installing Kennel Connection 7 with an existing version of SQL Server Welcome to the installation guide for Kennel Connection 7.  Follow the instructions below to get KC7 installed on your machine. Important:  If you are installing KC7 on your ...
    • Configuring KC6 to point to SQL

      After installing SQL server, you will need to tell the Kennel Connection program to point to the SQL server. Please follow the instructions below. Kennel Connection MUST be installed and running the latest service release before you can proceed.  ...
    • Restoring the Kennel Connection 7 database using Microsoft SQL Management Studio

      Restoring the Kennel Connection 7 database using Microsoft SQL Management Studio If you have been advised to use SQL Management Studio to restore your KC7 backup, there is a good chance it is because there are Windows or SQL Server permissions ...