Blog Post

Renaming Server with SQL

,

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

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating