@@servername returns NULL ??

  • Hi,

    MSSQL 2000/sp3; using Query Analyzer ...

    Any ideas why <SELECT @@servername> returns NULL and what are the steps to ensure that it picks up the server name?

     

    Many thanks. Jeff

  • Try SP_Addserver newname, 'local'

     

    You have to stop / star SQL for it to take affect


    KlK

  • Also, if you are using sql 2000 try

    cast(serverproperty('servername') as varchar(256))

    should return the name even if @@servername returns null

  • Hi Wesley, this method does work! Any idea why the @@servername returns NULL and this method doesn't?

    Many thanks. Jeff

  • It looks in a diffrent location for the server name @@SERVERNAME was used from 7.0 and back and has to have an entry in the sysservers table to work. that is what the sp_addserver does.

    Wes

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

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