Monday, March 12, 2012

Merge Replication Mysteriously Deleting Rows

I am running a simple merge replication in SQL Server 2000. I have one database that is the publisher, and a second database that is the subscriber. When I add a new row to the subscriber it will replicate to the publisher as expected. However, the new row at the subscriber will then be deleted without explanation. The row will remain at the publisher though.

Does anyone know why it is doing this?

What does your subset filter clause look like? If you insert a row that shouldn't be in your partition, merge replication will delete it from the subscriber. The whole point of filtering is to have only rows in your filter remain on the subscriber.|||

Some of the tables on the publisher have more columns than the respective tables on the subscriber. So there is vertical filtering. For example, a sensitive date will not be part of the replication.

|||I was talking about horizontal filtering. Are you filtering using HOSTNAME, or SUSER_SNAME, or some other static filtering?|||

I am using horizontal filtering on two tables. It's a simple "where bit = 1" filter. For example if a special flag is true then the publisher will replicate it to the subscriber. Of course, for the subscriber this value will always be true. Like I said, I am not doing anything really complex.

The weird thing is that these two tables are not the tables I am having problems with.

|||THen you need to provide more information about the article and values so we can help you. IS this article part of a join filter?|||

I think I have solved the problem. When I setup the horizontal filtering, it automatically extended some of the filters and created join filters. When I removed the join filters, the rows stopped being deleted. I will need to create some join filters to ensure that the subscriber only gets the data it needs, but the wizard created join filters all over the place.

Thanks for your help Greg

|||I haven't played around with the wizards in a while, but i will bet it can create joins for all the pk/fk relationships, which makes sense if you want horizontal filtering. Just keep an eye on it.

No comments:

Post a Comment