Sunday, July 8, 2012

FIX: The DELETE Statement Conflicted With The REFERENCE Constraint

ERROR:
The DELETE statement conflicted with the REFERENCE constraint "FK_NAME". 
The conflict occurred in database "databasename", table "dbo.tablename", column 'Colum_Name_ID'.
The row was not found at the Subscriber when applying the replicated command.
if @@trancount > 0 rollback tran 


Workaround:
In Transactional replication by default does replicate transactions in the order they occurred on the publisher database. You are getting this error because you are not enforcing cascading updates and deletes for replication.

Step 1. First you need to find on which table this FK constraint has been defined, through using Replication monitor.

Step 2. Right click on that FK, click Modify, you will get some popup box like below.


Step 3:  From above popup box, Select Cascade for delete and update specification field and click close and then save. 

Note:
DELETE CASCADE Option is that whenever the primary key record is deleted the foreign key record referencing it will be removed as well.

UPDATE CASCADE Option is that whenever the primary key record is updated the foreign key record 
referencing it will be updated as well.



I got error "The DELETE statement conflicted with the REFERENCE. How can I cascade delete a collection which is part. The DELETE statement conflicted with the REFERENCE constraint. TFS migration from 2008 to 2010 issue‎. the delete statement conflicted with the reference constraint cascade delete. the delete statement conflicted with the reference constraint the conflict occurred in database. the delete statement conflicted with the reference constraint fk_ aspnet_users. the delete statement conflicted with the reference constraint fk_subplan_job_id. the delete statement conflicted with the reference constraint fk_sysmaintplan_log_subplan_id. the delete statement conflicted with the reference constraint fk_dependencies1_objects. the delete statement conflicted with the reference constraint entity framework the delete statement conflicted with the reference constraint nhibernate. In sql server 2008. In sql server 2005. In sql server 2012. Cannot delete job. whats the solution. how to fix this replication issue. how to fix this transactional replication issue.

1 comments:

I solved this same issue by deleting the default maintenance plan located under management, maintenance. Once the default job was deleted all other jobs I had trouble with instantly disappeared in the job activity monitor.

Post a Comment