22 June,2017 by Tom Collins
I could not reliably determine the server's network name using @@servername. I executed a SELECT @@servername and the values returned were different to the SERVERPROPRTY(ServerName).
I was under the impression these values are the same , could explain to me the basic difference?
Answer: As a first step , this is the text straight from the MSDN site -
Although the @@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.
@@SERVERNAME returns the value from sys.sysservers. Typically you can adjust the value in sys.sysservers – by using the stored procedures
sp_dropserver 'MY_SERVER'; GO sp_addserver 'MYSERVER1', local; GO
Read more about using these stored procedures - SQL Server – Change @@servername - sp_dropserver and sp_addserver
You’ll notice if you make a change using these stored procedures and complete a SQL Server restart , there will be a new value for @@SERVERNAME. But SERVERPROPRTY(ServerName) will remain the same.
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |