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:

READ ALSO  Top Ten WordPress Plugins - September 2013
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:

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 Truncate SQL Server 2012 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 a lo...
Performing a System State Backup in Windows Server... Follow the instructions below to perform a system state backup in Windows Server 2003. We realize this is an old operating system, but there are a lot...
How to Install and Configure IIS Web Server with P... This guide will show you how to deploy your own IIS Web server, and enable it to run PHP on Windows 8 / Windows Server 2012. Thereafter this platform ...
How to create your own Cloud Storage Server In this tutorial, we are going to show you how to create your own cloud storage server. Head over to http://www.cloudways.com/ and click on Free Tr...