Skip to main content

Renaming a Standalone Instance of SQL Server

I needed to upgrade the underlying IO subsystem of one of my IO intensive SQL Servers. After some discussion with various teams it was decided that the best way to achieve this whilst minimising disruption was to build a fresh server with a new name and a fresh SQL Server installation.We could then  configure that server as an exact replica of the current production box, with a different IO configuration. We could then run tests using SQLIO and other business related loads without interfering with the current production environment and at the same time ensure that the new kit was up to the the task.

When it came to switch over we would be in position whereby  we could have both machines running at the same time, with network connectivity so we could copy the necessary database backup files between servers, and start our load processing running again. As this database is only used to house read-only databases, with a weekday daily load process the switch over time (downtime) could be kept to a minimum.

Anyway, I digress, When we were ready to switch over, to avoid having to re-configure things like firewall ports we wanted to reconfigure the new server to have the same name and IP address as the old server. So at the point of switchover we would rename the server and change its IP address to be the same as the old server and turnoff the old server. (But keeping it as a failback should something go awry.) when you rename a computer housing SQL Server…SQL Server picks up the new name at start up, no re-installation is needed but you do have to update the SQL Server meta data so things like

SELECT @@ServerName 



will initially return the incorrect information, the old server name.  You can change this by running the following script, obviuolsy replacing the dummy syntax with your server details:



sp_dropserver 'oldname\instancename'
GO
sp_addserver 'newname\instancename', local
GO



As you can hopefully tell from the above script my SQL instance was a named instance, to do this on a default instance you simply drop the \instance name from each stored procedure.



sp_dropserver 'oldname'
GO
sp_addserver 'newname', local
GO



To check that the meta data has been updated correctly you can run



SELECT @@ServerName 



Maintenance plans can be affected by a rename, and may break after the rename. So you can either delete before the rename and re-create afterwards or Microsoft supply a script to fix them. This can be found here.



Some caveats:




  • This will not work for a cluster, it is only for stand-alone servers.


  • It won’t work on replicated instances


  • If your database is mirrored you will need to break mirroring and re-configure after the rename.


  • if your computer is used in reporting services a different approach is needed more information can be found here.

Comments

Popular posts from this blog

SQL Server 2012 and Virtual Service Accounts

This post is written by David Postlethwaite
If you are using SQL Server 2012 you will probably have noticed that the default account for the SQL services has changed from that used in previous versions. With SQL 2005 and 2008 the default account for SQL service and SQL Agent service was “NT Authority\System”. This is one the built in accounts on a Windows machine, managed by the machine and selectable from a dedicated dropdown list

The Network Service account was introduced in Windows 2003 as an alternative to using the LocalSystem account, which has full local system privileges on the local machine, a major security concern.
The Network Service has limited local privileges easing these security concerns but when many services on a machine use the Network Service account it becomes harder to track which service is actually accessing resources and performing actions, because all the services are using the one Network Service account.
Also, this account, by default, has sysadmin per…

Always Encrypted

By David Postlethwaite

Always Encrypted is new features in SQL Server 2016 and it is also available in Azure SQL Database. Here you can encrypt columns in a table with a master key and a certificate so that they will appear as encrypted strings to those who don’t have the required certificate installed on their pc.
Once the certificate is installed on the computer then the unencrypted data can then be seen as normal.

The data passes from database to your application as the encrypted value, only the application with the correct certificate can unencrypt the data so it is secure across the wire. This will go some way to resolving the concern of people worried about putting their sensitive data on a shared server in the cloud such as Microsoft Azure and accessing the data across the Internet.

At the time of writing Always Encrypted is only supported with ADO.NET 4.6, JDBC 6.0 and ODBC 13.1 but expect other driver to become available.

The calling application (including SSMS) must also hav…

How to Setup Kerberos Correctly

David was in Copenhagen this weekend delivering his Kerberos talk Taming the Beast: Kerberos for the SQL DBA to SQL Saturday Denmark. I have had a quick chat with him via email since he got back and he said he had a great time. The event was very well attended with 280+ attendees and his talk was well attended.

I think David is planning submitting a few sessions to SQL Saturday events in Europe in the next few months so look out for him there and we'll keep you posted as to his whereabouts when schedules get finalised later in the year.

David has pre-recorded his Kerberos talk. You can watch on you tube and I have also embedded it in this post if you want to see what his kerberos talk  covers...



If we can help you with a SQL Sever problem visit our SQL Server Consulting page or contact us