Varying return values for Servername

  • Hi,

    I might be a little bit slow today, but can anyone explain this:

    SELECT

     CAST(@@SERVERNAME AS CHAR(30))

     , CAST(SERVERPROPERTY('Servername') AS CHAR(30))

                                                                 

    ------------------------------ ------------------------------

    XXX30LT009762\XXXX            XXX30LT009707\XXXX          

    (1 row(s) affected)

    I read the @@SERVERNAME topic in BOL, tried sp_addserver and sp_dropserver, however result is still the same. What am I missing to get in both cases the same return?

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Good luck

    I thought that it might have to do with a named instance, but tried it on my 64 bit named instance. But my results were not "messed up".

    Please post your solution as I think it will be very interesting!

     

     


    Andy.

  • SERVERPROPERTY in BOL has this

    The ServerName property of the SERVERPROPERTY function and @@SERVERNAME return similar information. The ServerName property provides the Windows NT server and instance name that together make up the unique server instance. @@SERVERNAME provides the currently configured local server name.

    ServerName property and @@SERVERNAME return the same information if the default server name at the time of installation has not been changed. The local server name can be configured by executing sp_addlinkedserver and sp_droplinkedserver.

    If the local server name has been changed from the default server name at install time, then @@SERVERNAME returns the new name.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Damn, I found the wrong name in several places in the registry. Just did a global hack and replaced all occurences with the correct name and hope nothing will break now. But, wtf, doesn't SQL Server just use one place to determine such information.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • It requires a sql service restart to reflect the change made by the stored procedures.

  • Yup, done! Since this is my laptop that wasn't much of a problem.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply