Replication error after server name change I have changed the computer name of the server where SQL Server 2008 R2 is installed.


Old name was WIN-OUJEKRMGXXX
New server name is KASURDYYY


When I try to configure replication, the following error occurs: 


  SQL Server Replication requires actual server name to make a connection to the server ... Specify the actual server name, WIN-OUJEKRMGXXX


I updated the server name in SQL Server in order to try to resolve the issue. I ran the following queries:

execute sp_dropserver 'WIN-OUJEKRMGXXX';
execute sp_addserver 'KASURDYYY', 'local';


...but the same error still occurs. I checked the server name :

select @@SERVERNAME -- returns WIN-OUJEKRMGXXX
select SERVERPROPERTY('SERVERNAME') -- returns KASURDYYY
sp_dropserver 'real-server-name' was giving an error about remote logins:


  There are still remote logins or linked logins for the server ...


Therefore, I executed the following query:

execute sp_dropremotelogin old_physical_server_name;


...but this gave the following error because of replication:


  There is no remote user '(null)' mapped to local user '(null)' from the remote server ...


Then I executed:

execute sp_removedbreplication 'database-name-on-which-publication-exist';
execute sp_dropdistributiondb 'distribution-database-name';


...still the same error. Finally I tried:

execute sp_dropdistributor @no_checks = 1, @ignore_distributor = 1;
execute sp_dropserver 'real-server-name';
execute sp_addserver 'nwe-server', 'local';


This resolved the issue.