http://www.sqlservercentral.com/blogs/ryanadams/2013/03/14/renaming-server-with-sql/

Printed 2014/07/24 12:02PM

Renaming Server with SQL

By Ryan Adams, 2013/03/14

I recently had to rename my laptop on which I have two SQL server instances.  I have a default instance and a named instance.  I actually have had the laptop renamed for awhile without any issues, but it’s not production and I don’t use it every day.  I first encountered the error while creating a schedule for a new SQL Agent job.  The error I received said that the server could not be found and provided the server name that it could not connect to.  I immediately noticed that it showed the previous machine name.  If you run into this error, then you need to update the sever name in sys.servers.  Here is how to make the update.

Default Instance

sp_dropserver 'PreviousName'
GO
sp_addserver 'NewName', local
GO

Named Instance

sp_dropserver 'PreviousNameInstanceName'
GO
sp_addserver 'NewNameInstanceName', local
GO

Now that sys.servers has been updated you need to restart SQL server for the changes to take effect.  Once SQL comes back up, you can verify success by running the following and ensuring the results match your new server name.

SELECT @@SERVERNAME


Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.