Posts Tagged ‘Difference between @@SERVERNAME and SERVERPROPERTY(‘SERVERNAME’)’

Its general understanding that @@SERVERNAME and SERVERPROPERTY(‘SERVERNAME’) will return same values. But once I get a different values for both means both

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


— 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’