How To Rename A SQL Server

Like some other posts recently, this one is the result of a conversation with a colleague at my new company, where I found they were unaware of something I took for granted; the ability to easily rename a comuter which has a stand alone instance of SQL Server installed.

I do this fairly often as I use quite a lot of Virtual Machines for testing different configurations, but I don’t want to have to build a new one every time, so I make copies of a base VM and rename it each time I want a new one (there is often more than one running at any one time and I want to avoid conflicts).

As well as renaming the machine inside the VM, I also rename the SQL Server to make sure it matches the name of the machine; I’ve had problems before with Microsoft Dynamics GP when I’ve not done so.

Doing this is actually very simple. After renaming and restaring the computer, I always confirm the current name of the SQL Server;


SELECT @@SERVERNAME
GO

The script to rename SQL Server is (assuming the old machine name, returned by the previous script, was DB1 and the new one SQL1);


EXEC sp_dropserver 'DB1'
GO

EXEC sp_addserver 'SQL1', LOCAL
GO

Restart the SQL server to complete the renaming operation.

This script will work with named instances of SQL as well as the default one as shown above. If it had been an instance of SQL named db1\SQL2008R2 the script to rename it would be;


EXEC sp_dropserver 'DB1\SQL2008R2'
GO

EXEC sp_addserver 'SQL1\SQL2008R2', LOCAL
GO

Ian Grieve

About Ian Grieve

Ian is a Microsoft Dynamics GP certified consultant specialising in the delivery of Microsoft Dynamics GP projects and currently working for Perfect Image Ltd., a Microsoft Partner and VAR in the North East of England. Ian has worked with Microsoft Dynamics GP since 2003 and, over the nine years since, has dealt with all aspects of the product life-cycle from presales, to implementation, to technical and functional training, to post go-live support and subsequent upgrades and process reviews. In his spare time, Ian runs the azurecurve | Ramblings of a Dynamics GP Consultant blog dedicated to Microsoft Dynamics GP and related products.
This entry was posted in Dynamics, GP, Microsoft, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008 and tagged , , , , , . Bookmark the permalink.

2 comments on “How To Rename A SQL Server

  1. Pingback: How To Rename A SQL Server | azurecurve - DynamicAccounting.net - GP Technical Blogs - Microsoft Dynamics Community

  2. Pingback: How To Rename A SQL Server | azurecurve - DynamicAccounting.net - GP Technical Blogs - Telligent

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>