SQL Server 2019 Instance Name Change

Rich 21 Reputation points
2022-03-15T17:08:06.187+00:00

I am running SQL 2019 on Windows 2019 server and have come across an issue I have not seen before and cannot find a resolution on the web. I have went through the normal process of changing the Instance name by using the following..

EXEC sp_dropserver '<old_name\instancename>';

GO

EXEC sp_addserver '<new_name\instancename>', local;

GO

I rebooted the server afterward but I have to use the original instance name to actually connect but if I run

Select @@servername it returns the new instance name.. It acts like Windows Server 2019 is blocking the final piece the name change. Anybody seen this and have a fix?

Thanks

Rich

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,225 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,672 questions
{count} votes

Accepted answer
  1. LiHong-MSFT 10,051 Reputation points
    2022-03-16T02:43:28.873+00:00

    Hi @Rich
    sp_dropserverand sp_addserver can only be used to rename the part of the instance name that corresponds to the computer name.
    So you could use it to rename your server name old_name to new_name, but you can't change the instance name without reinstalling.
    For more details can be found on MSDN.
    Here is a similar thread which you can refer to: [renaming a SQL Server with installed named instances closed

    Best regards,
    LiHong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 114.6K Reputation points MVP
    2022-03-15T22:43:23.64+00:00

    You can't change the instance name. (At least not in any supported way. You could try hacking the registry, rename files etc, but you would be on your on.)

    The process you describe is exactly for changing the value of @@servername, typically in the case you have renamed the machine.

    0 comments No comments

  2. Olaf Helper 45,371 Reputation points
    2022-03-16T06:49:21.453+00:00

    I have went through the normal process of changing the Instance name by using the following..

    There is no "normal process", because it is not possible to change a SQL Server instance name.

    With the used command you just change a registered server name, nothing else; that has no effect on external connections.

    0 comments No comments

  3. Rich 21 Reputation points
    2022-03-16T13:00:52.227+00:00

    I have always done this when I have indeed changed the server name itself. This seems a little silly that you cannot then use the same command for changing just the instance name only.. Thanks for all the help.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.