Sql-server – Merge Replication – Deleting from the subscriber database

merge-replicationreplicationsql server

I have 2 SQL Server instances where I use merge replication on a database. A developer accidentally inserted data to both the subscriber and publisher at the same time. Now I have data in both databases but with different rowguids.

Q: Can I delete those rows with different rowguids from the subscriber and the rows in the publisher remain untouched? If so, will the rows from the publisher replicate back to the subscriber but now with the same rowguid?

Best Answer

If the same logical row has two different rowguid values at publisher and subscriber, then you're having a conflict.

Changes are replicated using the rowguid column, so different rowguid means different rows as far as replication is concerned. You can safely delete the duplicate row at the subscriber and the changes won't be replicated to the publisher (the row with a matching rowguid is not present at the publisher due to the upload conflict).

Once the row is deleted at the subscriber, the merge agent will be able to insert at the subscriber the row from the publisher.