**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.
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';
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