Error message (the distribution server is incorrectly installed when the replication function is configured and disabled .) :
1. The distribution server or distribution database cannot be found for the local server. The distributor may not be installed, or the local server may not be configured as the publisher on the distributor.
2. SQL Server cannot disable publishing and distribution on "XXXX.
------------------------------
Other information:
An exception occurred when executing a Transact-SQL statement or batch processing. (Microsoft. sqlserver. connectioninfo)
------------------------------
The distribution server is not correctly installed, so the database cannot be published.
Cause:
The server has changed the host, so the machine name is different at this time. Previous release projects are all previous machine names, and all released projects cannot be deleted successfully on the current machine name, eventually, the replication function becomes unavailable. Since the SQL replication function is addressing by machine name, the distribution server is prompted to be correctly installed because the new machine name is different from the old one after the host is changed.
The solution is as follows:
// Clear all subscription and release items of the dbname Database
All data that has been published or subscribed to on the server can be cleared with the following command.
Sp_removedbreplication 'dbname'
// If the previous machine name has a publish or subscribe project, run the following command to view it:
Use dbname
Select * From syspublications
Use dbname
Select * From syspublications
----------------------- The following are some practical commands ----------------------------
// View the linked server
Select * From SYS. Servers
// View the server instance name
Select @ servername
Use master
// Enable database publishing and merging
Exec sp_dboption 'dbname', 'merge publish ', 'true'
// Start Database Replication
Exec sp_dboption 'dbname', 'published', 'true'
// View the registered server instance
Exec sp_helpserver
Note: The preceding dbname indicates the database name. Write based on your own data name