I've just recently setup a custom replication for my subscriber database, as described in another post here. Basically, when the publisher pushes a new record to the subscribers, the stored procedure will also insert a replicated time into an extra column in the table, and insert a new record to a log table.
My problem occurs when trying to replicate the log table back to the main publication database. This is what I did:
- In the database where the log table is located, I setup a new transactional replication, and set it to create a snapshot.
- Once the publication is created, I create a new push subscription, and set it to initialize immediately.
- Once the subscription is created, I checked the synchronization status and confirm that the snapshot is applied successfully.
Now here's the weird part: if I manually add a record to the log table using the SQL Server Management Studio, the record will be replicated fine. If the record is added by the custom replication stored procedure, it will not. The status will always display "No replicated transactions are available".
I have no clue why the publication is behaving this way: I really don't see how it is treating the data inserted by the custom replication stored procedure differently.
Can someone explain what may I've done wrong?
UPDATE: I finally have an answer for this problem a few months ago, just that I never got around to update this question. We have to log a support call to Microsoft, but we got a working solution.
ANSWER: To resolve the problem, when adding a subscription, you need to run the script like below:
sp_addsubscription @publication = 'TEST', ..., @loopback_detection = 'false'
The key to the solution is the last parameter shown above. By default, the generated subscription script will not have this parameter.