October 31, 2005 at 2:43 pm
Hi,
SELECT @@Servername is returning NULL for one of my databases
but if i say:
SELECT CONVERT(char(20), SERVERPROPERTY('servername'))
its giving the servername correctly.
Problem is that we are using SELECT @@Servername at a number of places in our SPs and hence all of them are breaking.
Please advise how to resolve this.
Regards,
RSingh
October 31, 2005 at 3:02 pm
server name is stored in sysdatabases. How do you connect to get @@servername? Are you on a server machine with sysadmin rights? if something happened to your server name in this case you may want to execute sp_dropserver and sp_addserver specifying Local as a server, similar to when you are changing a server name.
@@Servername article in BOL says:
".....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.
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...."
So it could happen that they changed the name of the server and that is why you have problems with @@servername. Do sp_addserver.
Regards,Yelena Varsha
October 31, 2005 at 3:10 pm
Thanks Yelena for the reply.
But i forgot to mention that i had alread tried the following:
October 31, 2005 at 10:39 pm
[snip]
Posting created 2 replies, did not post twice this time...
Andy
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply