Why does SharePoint stop working after a rename? You renamed the machine, Windows was happy, and SharePoint stopped. The cause is almost always the same. SQL Server keeps its own copy of the server name and renaming Windows does not update it. Two commands fix the database side, and then you have to go and find everything still holding the old name.

Prove It Before You Fix It
One query settles whether this is your problem:
SELECT @@SERVERNAME AS sql_thinks_it_is,
SERVERPROPERTY('MachineName') AS windows_says,
SERVERPROPERTY('ServerName') AS computed_name,
SERVERPROPERTY('InstanceName') AS instance_name;If the first two disagree, you have found it. @@SERVERNAME reads a value stored at install time. MachineName reads Windows. Renaming the computer changes one and not the other.
Why SharePoint Cares So Much
SharePoint stores the database server name in its configuration database. It also stores it in the registry on every server in the farm. It uses that name to connect, and to check it is talking to the right farm.
So it holds the old name in several places, and SQL Server now reports a different one. Many of SharePoint’s own health checks compare those values. That is why the failures look so varied.
Fixing the SQL Server Side
-- a default instance
EXEC sp_dropserver 'OLDNAME';
GO
EXEC sp_addserver 'NEWNAME', 'local';
GOFor a named instance you pass both parts:
EXEC sp_dropserver 'OLDNAME\SQLPROD';
GO
EXEC sp_addserver 'NEWNAME\SQLPROD', 'local';
GOThen restart the SQL Server service. The new value is not picked up until it starts, so skipping the restart makes people think the commands failed.
SELECT @@SERVERNAME AS sql_thinks_it_is;Run that again after the restart. It should now agree with Windows.
When sp_dropserver Refuses
You will get an error if the old name is still referenced as a remote or linked server. Look first:
SELECT name, product, provider, data_source, is_linked
FROM sys.servers
ORDER BY server_id;Server id 0 is the local server. That is the row you are changing. Anything else pointing at the old name needs handling separately, including replication, which does not let go quietly.
If the instance is a replication publisher or distributor, stop. Replication stores the server name in many places. A rename means removing and rebuilding it, not patching it.
What Else Still Holds the Old Name
This is the part people miss, and it is why the fix sometimes seems not to work.
Database mail profiles and their accounts. Agent jobs with the old name written into a step. Maintenance plans, which store a connection with the name inside it. Those are the most common leftover. And linked servers pointing back at the machine itself.
SELECT j.name AS job_name, s.step_id, s.step_name, s.command
FROM msdb.dbo.sysjobs AS j
JOIN msdb.dbo.sysjobsteps AS s ON s.job_id = j.job_id
WHERE s.command LIKE '%OLDNAME%' OR s.server LIKE '%OLDNAME%';Outside SQL Server there is more. Application connection strings, ODBC data sources, monitoring agents and firewall rules. Certificates issued to the old name. Any SPN registered in the domain. Kerberos fails in a confusing way when the SPN still names the old machine.
The SharePoint Side
SharePoint has a supported way to point a farm at a renamed server. It uses an alias, so the farm never learns the new name at all. That is usually the smaller job.
A client alias on each SharePoint server maps the old name to the new one. The farm keeps asking for OLDNAME. The alias sends it to NEWNAME. Nothing in the configuration database changes.
That is a legitimate permanent answer, not only a workaround, and for a large farm it is often the right call.
What I Would Do Differently Next Time
Decide the name before installing SQL Server, because renaming afterwards is never free.
Better still, have applications connect through an alias or a DNS name from the start. Then the day the hardware changes, nothing else has to.
A rename is not one change, it is the name of a thing that several other things wrote down.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.





9 Comments. Leave new
Hi pinaldave,
I am working on Sharepoint 2007. I am facing problem with SPSites when My computer name is changed. No sites is working after I change the Computer Name. I follow the steps provided by you to solve this Issue. Once the Configuration wizard is Completed successfull ( That is last step ) it is open the central administration site. In Central administration site one option is available to check the web application lists. when i open the link it is showing only the Central administration Site in Web application list ( Before changing the Computer Name i have 10 Shrepoint sites in IIS which are working without showing any error) How can i make them to work.
Thanks
Nazeer Basha Shaik
Nazeer,
Have you figured out how to get your sites to work? I was afraid that would happened if I followed this proceedure, so I wanted to know if it would all work out before I went ahead with this.
If anybody has information on how to get your old sites back up and running after you change server names it’d be much appreciated.
Thank you.
I have an existing server farm and the SQL Server computer changed. I cannot connect to the SQL Server and when I have tried to run through the wizard I first disconnect from the farm and again re-run the wizard. But, I cannot connect the existing SQL Server under the new name. Any help would be great.
Thanks, Josh
SQL Server 2005
Sharepoint 2007
Hey Pinal Dave, see – if you use SQL aliases you can change the server name very easily. You just need to plan it when you do your initial SharePoint installation.
DDK
MOSS + SqlExpress ( Server )
== Migrated to ==>>
MOSS ( SERVER1 ) + sql 2005 ( server2)
After migration am not seing any sites in IIS on Server1
Any help please..
Thank you for this procedure. Works great with SharePoint 2010 also.
The only thing different is in IIS Manager, the node to delete will be SharePoint Central Administration v4 instead of v3.
Ryan,
Did you have old sites you managed to get working again? I’m trying this with 2010 as well, but I’m afraid I’ll lose my sites.
Just an FYI you can do this much easier by simply changing the Registry Key which contains the settings for connection to the Configuration database.
If you go this route you do not have run the STSADM command and no need to run the configuration wizard to rebuild Central Admin.
Thanks yar Ap ne mara Sara masal hal kar dia …
Thank’s Friend you have Solved all my problems