Wednesday, July 26, 2006

SQL Server: Change Server Name

Run following command to change the server name in sys.servers system table:

   sp_dropserver @server = 'old_server_name'
   GO
   sp_addserver @server = 'new_server_name', @local = 'local'
   GO


Restart the server, and use command below to verify:

   SELECT @@SERVERNAME

or execute command below (for SQL 2005):

   C:\>sqlcmd -A
   UPDATE sys.servers SET name = 'new_server_name'
   GO