We have a production database (2008 R2) that is enabled for replication as a publisher and subscriber with a remote distributor (distributorA).
We restored a copy of this database onto a new 2016 server. Now we want to configure replication on the restored copy as a publisher to our new distributor (distributorB).
We configured distributorB with a new distribution database and configured the new 2016 server as a publisher to distributorB.
Back on the new 2016 server, we ran sp_adddistributor to point it to distributorB. Everything works as expected so far.
Now we run the following command on the restored db to enable replication sp_replicationdboption @dbname = 'restoreddb', @optname = 'publish', @value = 'true'. That completed successfully.
This is where the problem starts to manifest itself. When I tried to create a new publication now, at the end of the publishing wizard, it errored out saying it can't find dbo.syspublications.
I check the system tables on the restoredb and find that some of the tables required for replication have not been created (syspublications, sysarticles, syssubscriptions and etc), but some have (sysreplservers and MSPeer*). I can, however, see that this database has 'transactional' checked in publication databases under publisher properties. When I try to uncheck it and hit OK, it gives me the following error
Invalid object name 'dbo.syssubscriptions'.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
I tried using sp_removedbreplication to cleanup any remnants of replication settings from the database to start afresh, but that didn't seem to help at all.
I think the problem here is somehow the remnant replication settings from the database's 'former self' is interfering with setting up replication again with a different distributor.
So my question is why some of the replication system tables were not created? How do we remedy this?