SQL Server Difference between @@SERVERNAME and SERVERPROPERTY(‘SERVERNAME’)

Its general understanding that SQL Server Difference between @@SERVERNAME and SERVERPROPERTY(‘SERVERNAME’) will return same values. But once I got a different values for both

Select @@SERVERNAME
Select SERVERPROPERTY(‘SERVERNAME’)

were returning different name,  I got answer @ BOL as

@@SERVERNAME function and the SERVERNAME property of SERVERPROPERTY function may return strings with similar formats, the information can be different. The SERVERNAME property automatically reports changes in the network name of the computer.In contrast, @@SERVERNAME does not report such changes. @@SERVERNAME reports changes made to the local server name using the sp_addserver or sp_dropserver stored procedure.

To resolve the issue, Just follow below steps,

   

— To see Servername

sp_helpserver

— Removes server from the list of known servers on the local instance of SQL Server.

sp_dropserver ‘WRON_SERVER_NAME’, null

— Add server to the local instance of SQL Server.

sp_addserver ‘REAL_SERVER_NAME’,’LOCAL’

 

Regards

Virendra Yaduvanshi

Like us on FaceBook Follow us on Twitter

Join the fastest growing SQL Server group on FaceBook

   

Leave a Reply

Your email address will not be published.