Jan 04 2024 01:39 AM - edited Jan 04 2024 07:28 AM
We wanted to have a DR setup for our SQL Server databases.
So for testing purpose we went ahead with Transactional Replication.
Setup
The system is working as expected, but following behaviours are observed:
Problem
I wanted to take this same setup to Production, but this behaviour of Insert after Delete is stopping me to proceed ahead.
What the root cause of this issue?
Is there a way to overcome it or this is the natural behaviour?
How to avoid such situations?
Replication Monitor shows Error:
The row was not found at the Subscriber when applying the replicated DELETE command for Table '[dbo].[DP000043]' with Primary Key(s): [MGrCode] = 101, [EffDate] = 2017-09-11 00:00:00.000, [SrNo] = 1
Jan 04 2024 10:12 PM
Answer as per my investigation:
Normally this error occurs when an UPDATE or DELETE statement is executed by the publisher for a primary key value and the record (against which UPDATE/DELETE executed) does not exist in the subscriber database.
There are multiple reasons that could cause this: