none
@@Servername is NULL (Sql server 2008)

    Question

  • I have installed SQL Server 2008

    Server name was Server1 and then modified to server2

    @@Servername returns "Server1; where @@serverproperty('servername') returns 'server2'

    I dropped the server name using  sp_dropserver "Server1". Now @@Servername returns NULL.

    Then I tried adding the server using sp_addserver "Server2", local. But this returns an error "Server2" already exists. I tried the "duplicate_ok" and the command is executed successfully, but @@servername is still NULL.

    In all cases, I restarted sql serger service and agent. How can I update the @@servername to NULL?

     

    Wednesday, October 12, 2011 10:18 PM

Answers

  • Hi Did you follow steps as mentioned here when you were adding and dropping servers?  Just try redoing it to the required name you would like.

    http://msdn.microsoft.com/en-us/library/ms143799.aspx

    Also found a good post by Tibor

    http://www.karaszi.com/SQLServer/info_change_server_name.asp

    And found this on a documentation

    "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."



    • Edited by SQL_Jay Thursday, October 13, 2011 3:53 AM
    • Proposed as answer by Peja Tao Thursday, October 13, 2011 7:20 AM
    • Marked as answer by irislogic Thursday, October 13, 2011 5:35 PM
    Thursday, October 13, 2011 3:43 AM

All replies

  • Hi Did you follow steps as mentioned here when you were adding and dropping servers?  Just try redoing it to the required name you would like.

    http://msdn.microsoft.com/en-us/library/ms143799.aspx

    Also found a good post by Tibor

    http://www.karaszi.com/SQLServer/info_change_server_name.asp

    And found this on a documentation

    "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."



    • Edited by SQL_Jay Thursday, October 13, 2011 3:53 AM
    • Proposed as answer by Peja Tao Thursday, October 13, 2011 7:20 AM
    • Marked as answer by irislogic Thursday, October 13, 2011 5:35 PM
    Thursday, October 13, 2011 3:43 AM
  • Reviewed the documentation here http://msdn.microsoft.com/en-us/library/ms143799.aspx

    Deleted a publication with a old computer name. Reporting services were turned and used to test some reporting. I disabled it since we do not reporting services at this moment.

    Used the sp_addserver and now the @@servname has been updated.

    I can continue with my replication setup :)

     

    Thank You

     

     

    Thursday, October 13, 2011 5:35 PM