January 12, 2005 at 1:31 pm
Is SERVERPROPERTY ('Servername') the proper method rather than @@ServerName? Both methods should return the same value but @@ServerName is not always correct. Is @@ServerName provided for backward compatability only?
January 12, 2005 at 1:54 pm
The biggest difference is ServerProperty('ServerName') reports network name. @@Servername does not.
So my understanding is if you change the name of your SQL Server, it will not be reflected with @@Servername unless you sp_addserver and sp_dropserver (which are for backward compatabilities sake)
January 13, 2005 at 3:31 am
@@SERVERNAME queries the table sysservers, hence why sp_addserver etc is required.
Correctly:
ServerProperty('ServerName') does not return the network name. It returns "machinename\sqlinstancename" or "machinename" if the default instance.
ServerProperty('MachineName') gives the actual server network name
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply