I want to change my SQL Server's name.

Currently I am connecting to SERVER1\SQLSERVER. SERVER1 is the machine name. I want to change it so I could connect to SERVER2\SQLSERVER and keep SERVER1 as the machine name.

I tried:

sp_dropserver 'SERVER1\SQLSERVER'
sp_addserver 'SERVER2\SQLSERVER', local

Then I restarted the server.

If I verify I get the new server name:

select @@servername

Looks like the name was changed but i cant connect to SERVER2\SQLSERVER while the SERVER1\SQLSERVER connection still works.

What am I missing here ... and is this even possible?

  • 2
    what happens if you run the following DOS command: nslookup SERVER2 – Stuart Moore Feb 5 '13 at 12:47
  • says "unknown server" in both examples SERVER1 or SERVER2. – no9 Feb 5 '13 at 12:50
  • 1
    Is your DNS server working? Server1 should be your current name and should be translated to something like: "domain server name + IP | current server name + IP". – Marian Feb 5 '13 at 13:03
  • Well, according to the official documentation it should work. Now see if there's any exception or error that you need to check. – Marian Feb 5 '13 at 13:23
  • 1
    I don't have a similar machine to test with, but have you tried with server aliases? – Marian Feb 5 '13 at 13:39

If you aren't changing the physical server's name you'll need to change the name that SQL Server knows back.

sp_dropserver 'SERVER2\SQLSERVER'
sp_addserver 'SERVER1\SQLSERVER', local

You then just need to put an alias in DNS so that when people try to connect to SERVER2 then are redirected to SERVER1 without knowing about it. Specifically you'll want (or you'll want your sysadmin) to put a CNAME record into DNS pointing SERVER2 to SERVER1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.