Saturday, February 25, 2012

Merge Replication and Unique contraints

Hi,

I have a slight problem which I'm sure must be a common happening. Here's my problem.

I'm using Merge replication and I have a table the has a unique contraint on a non primary key column (the column is called [name]). The thing that goes wrong (for me) is that when a new record is added in a subscriber and a new record is added in the publisher before a synchronization and both records have the same [name] value then when the merge agent runs I get an unresolved conflict because of a unique index violation.

I've read the BOL and I'm left thinking that in order to solve this problem then I must use a custom resolver. Is this the best way of handling such a conflict? Actually if it is I'm still a little stuck as I'm not sure what I could do to help the situation inside the custom resolver anyway!!

Any help would be much appreciated.

Thanks

Graham

For handling this issue, the easy way is to also replicate that unique constraint. If both publisher and subscriber side have constraint, non-unique update won't happen before merge sync.

To do so, published article shema_option has to include "Copy unique Key Constraint", you can either through UI or SP to implement it.

Thanks

Yunjing

No comments:

Post a Comment