Recently one of our customers ran Bulk insert into one of their databases which was in merge replication and later on found that Merge replication has stopped working.

1. When data is loaded into tables using the bcp Utility or the BULK INSERT command, by default, the merge replication triggers that maintain tracking data in the MSmerge_contents system table are not fired. You can either force the merge replication triggers to fire as the data is loaded

2. It is known and expected behavior which is also documented in the article

3. So incase if you want to perform Bulk Insert on a database which is in merge replication we can use any of the following approach

a)  Execute the bulk copy using the FIRE_TRIGGERS option.

b) On the database into which data was inserted, execute sp_addtabletocontents (Transact-SQL). Specify the table name into which the data was inserted for @table_name

4. In our case, Customer did not use FIRE_TRIGGERS and even sp_addtabletocontents did not help us resolve the issue

5. Finally the only supported way to resolve the issue was to reinitialize the merge replication which will ensure the convergence between the publisher and subscriber.

If you are using Merge Replication in your environment and if you wish to perform Bulk operation on the database please make sure you use either method 3a or 3b described above


Parikshit Savjani
Premier Field Engineer

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *