Violation of Primary Key in Merge Replication

I have one Publisher and one Subscriber. They have UK (Col1, Col2), PK is col1 + col2, and the MERGE REPLICATION adds a ROWGUID. Sometimes they insert the same row when they are offline ( they generate the same UK, it's not IDENTITY column), because of it, they generate different ROWGUID for the same row. Then, when I run the JOB for Merge Replication, I have a PRIMARY KEY violationI need to use the UK instead of ROWGUID. It is possible?

Example:

Table_1 (Publisher)
Name: John (UK)
ID: 1234 (UK)
ROWGUID: xxxxx (Created by Merge Replication)

Table_1 (Subscriber)
Name: John (UK)
ID: 1234 (UK)
ROWGUID: yyyyy (Created by Merge Replication)


April 22nd, 2015 2:41pm

Hi Alex R,

From your description, you want to use the UK(col1, col2) instead of ROWGUID, right? If so, it is not possible.

To use your own column as rowguid column in merge replication, your column should have the following properties:

Should be of Uniqueidentifier datatype

Should have the ROWGUIDCOL property set

Should not allow NULLs

Should have a default of newid()

Also please note that only one column can have the ROWGUIDCOL attribute in a table, in other words, we can only specify one column to be rowguid column in merge replication.

Reference:
https://msdn.microsoft.com/en-us/library/ms152746.aspx?f=255&MSPPError=-2147217396

Thanks,
Lydia

Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2015 4:09am

Do you have any idea how can I solve this? Because the Publisher and Subscriber can insert the same row when they are offline. When they synchronize I get primary key violation error.

I need to chose one, but even in Replication Conflict Viewer, when i try to Submit Loser, I get this error.

April 24th, 2015 5:16pm

Do you have any idea how can I solve this? Because the Publisher and Subscriber can insert the same row when they are offline. When they synchronize I get primary key violation error.

I need to chose one, but even in Replication Conflict Viewer, when i try to Submit Loser, I get this error.


Hi Alex R,

Could you please post the full error message for analysis?

Thanks,
L
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 3:34am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics