Tuesday, July 18, 2006

FAQ : @@Servername and SQLServername result does not match

Why @@Servername and Serverproperty(‘Servername’) is giving different name.
Why my default sql server instance name does not match the machine name?

If you rename the Physical Machine (OS) which was already installed with an SQL Server default instance the ServerProperty() function will show you the lastest name and the @@Servername function will show you the old name. Because SQL Server Setup sets this @@Servername variable to the computer name during installation. To synchronize the result of @@Servername with the new name, you need to drop the old servername and add the new server name using sp_DropServer and sp_AddServer

Steps are as follows

--Check Servername
select @@Servername,Serverproperty('Servername')

-- (a) Drop old server name
Exec Sp_dropServer ‘OldServername’

-- (b) –Add new servername
Exec Sp_addServer ‘NewServerName’, 'Local'

-- (c) See the changes
Exec sp_Helpserver

-- (d) Check Servername
select @@Servername,Serverproperty('Servername')

Refer :

No comments:

Locations of visitors to this page