sql server 2012

Renaming a Computer with SQL Server Instance

After SQL Server installation internal SQL Server is based on the host computer name. However, when you are changing the host name, old SQL server name in the metadata (stored in sys.servers ) is not updating automatically. But you dont need to reinstall it completely to change the name of SQL server! In this step-by-step tutorial we will show you how to change server name in a correct way with a standalone non-clustered instance of Microsoft SQL Server. This manual is applicable for Microsoft SQL Server from 2000 to 2012 versions.

Tip. You cant change the SQL Server Instance name without a complete reinstalling.

Now lets start. Open SQL Server Management Studio and check the current host name and SQL Instance name:

Select @@ServerName ServerName, Host_name() HostName

SQL query

Now you can see:

  • Current Server Name: DESKTOP-V20E3PO
  • Current SQL Instance Name: DESKTOP-V20E3PO\SQLDB

Let’s rename the host and restart server by running command:

Rename-Computer -NewName Sql-Srv1 -Restart

Tip. You can change the name of host from My Computer properties also.

After rebooting, try to establish connection using old SQL server name DESKTOP-V20E3PO\SQLDB. You will get an error, because the server name was changed before.

connect to server error

A network-related or Instant-specific error occurred when you was trying to establish connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and SQL Server is configured to allow remote connections. (provider: SQL Network Interface, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server)

Re-check Instance name and hostname:

Select @@ServerName ServerName, Host_name() HostName

SQL query hostname

In our case, it is clear that SQL instance name does not match the name of computer and still referring to old host name DESKTOP-V20E3PO.

To change hostname for named SQL Instance run following TSQL commands:

Drop old server name from server list:

sp_dropserver "DESKTOP-V20E3PO\SQLDB";

Add new server name as default:

sp_addserver "Sql-Srv1\SQLDB", local;

To Rename Host of a SQL Server default instance run the following:

sp_dropserver ″old_name″;
sp_addserver ″new_name″, local;

SQL query commands sucessfully

Additional steps

You can get an error while executing sp_dropserver stored procedure:

Msg 15190, Level 16, State 1, Procedure sp_dropserver, Line 56

There are still remote logins or linked logins left for the server DESKTOP-V20E3PO.

You have to drop the remote logins first.

For Default instance:

sp_dropremotelogin DESKTOP-V20E3PO;

For Named instance:

sp_dropremotelogin DESKTOP-V20E3PO\SQLDB;

These commands should be executed for each SQL instance on the machine.

Verify that server name in the metadata (sys.servers) was updated:


SQL query servername

SQL query sysservers

Rename was successful!

The only thing you need to do is to restart SQL Service:

net stop MSSQL$SQLDB && net start MSSQL$SQLDB


  • You can rename computer name in such way only with Standalone SQL server. To rename SQL Server under Failover Cluster use Cluster Management snap-in.
  • You cannot rename a server involved in replication or database mirroring.
  • If you have installed Reporting services, after renaming it may not be available. Find out more here.

You may also like:

How to Migrate DHCP to Windows Server 2016 Migrating the DHCP service from the old server to the new Windows Server 2016 with saving of all the settings of the old server is quite easy. If the ...
How to Truncate SQL Transaction Logs Transaction logs in SQL Server 2012 tend to grow over time, which can sometimes fill all your available disk space. To avoid this, SQL Server has Trun...
Applications deployment by Make and Model using MD... In this article we will show you guys how to configure your SQL database within MDT 2013 Update 1 and configure it to start using the Make and Model s...
How to Setup FTP Server in Windows 10? FTP (File Transfer Protocol) is a popular Internet data transfer protocol. You can use FTP to transfer files between a remote server and a local PC. F...
The RPC server is unavailable 0x800706BA Most likely, a lot of you already faced with an error The RPC server is unavailable. (Exception from HRESULT: 0x800706BA), when you tried to connect t...
  1. Posted by Максим Чистяков

Add Your Comment