SQL Server Performance

select @@servername

Discussion in 'General DBA Questions' started by gk_sql, Oct 30, 2006.

  1. gk_sql New Member

    Hi,

    I'm having sa access in the server , when i tried select @@servername it is showing null. I have the IP address , i pinged and got the servername.All othere sql servers are listed in sysservers except the above one.

    Can anybody knows why select @@servername is not showing the servername?

    GK

  2. ranjitjain New Member

    try SERVERPROPERTY('servername')
    This linkhttp://msdn2.microsoft.com/en-gb/library/ms187944.aspx
    says that SERVERNAME property automatically reports changes in the network name of the computer.
    In contrast, @@SERVERNAME does not report name changes. @@SERVERNAME reports changes made to the local server name using the sp_addserver or sp_dropserver stored procedure
  3. dineshasanka Moderator

    @@Servername of null can happen if there is no entry in sysservers for server_id 0. check sysservers with this:


    select * from sysservers where server_id=0

    If this returns 0 rows you can add the local server with

    sp_addserver '<servername>', local

    you will need to restart the server for this to take effect.



    ----------------------------------------
    Contributing Editor, Writer & Forums Moderator
    http://www.SQL-Server-Performance.Com

    Visit my Blog at
    http://dineshasanka.spaces.live.com/

Share This Page