Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

renaming a SQL Server with installed named instances [closed]

We have a hosted server that is named, by the hosting company, as something like WinEnt99. We would like to rename it to something more meaning like OurMonitor1.

We have already installed a few instances of SQL Server 2008 R2.

Is there anything that we need to (re)configure in SQL Server / SSMS ?

I have an application that was reading the database settings from the registry, and connecting the database fine. Now, it won't connect to the database. The only thing that I can think of is that we renamed the server last week sometime.

EDIT 02 Oct 2012:- The Server is being renamed. The named instances are not.

I've run

sp_helpserver
select @@servername

Which showed the old server name, and

sp_dropserver 'Old Server Name\Instance_name'
go
sp_addserver 'New Server Name\Instance Name','local'
go

Then confirmed the details in

sp_helpserver
select @@servername
like image 426
cometbill Avatar asked Oct 01 '12 15:10

cometbill


People also ask

Can you rename your instance of SQL When you have installed it?

SQL Server does not support renaming computers that are involved in replication, except when you use log shipping with replication. The secondary computer in log shipping can be renamed if the primary computer is permanently lost.

How do I rename an existing SQL Server database?

If you are using SQL Server, you can set the database to single-user mode to close any open connections and prevent other users from connecting while you are changing the database name. In Object Explorer, expand Databases, right-click the database to rename, and then select Rename.

How do I rename a SQL Server instance 2017?

The process to change a SQL Server instance name has not changed from how it is done on a Windows based SQL Server. We need to drop the existing SQL Server instance name using system stored procedure sp_dropserver and then we need to add the new SQL Server instance name using system stored procedure sp_addserver.

How do I rename a SQL Server 2008 r2 instance?

There's no way to rename the instance. You have to uninstall the instance, and then install a new instance. (Or install the new instance, move the databases to the new instance, then disable or uninstall the old instance).


1 Answers

First collect the output of the current instance configuration. You can get the instance name stored in the SQL Server metadata.

Make sure you have backup of all the database if you are changing the production server instance name.

sp_helpserver
select @@servername

You can change the instance name using below query. Default Instance

sp_dropserver 'old_name'
go
sp_addserver 'new_name','local'
go

Named Instance

sp_dropserver 'Server Name\old_Instance_name'
go
sp_addserver 'ServerName\New Instance Name','local'
go

Verify sql server instance configuration by running below queries

sp_helpserver
select @@servername

Restart the SQL Server Services.

net stop MSSQLServer
net start MSSQLServer

[Update]

You cannot change connection instance name as this action is not supported. Only option is re-install SQL server. See answer in MSDN here

like image 153
btomas Avatar answered Sep 29 '22 21:09

btomas