SQLTeam.com | Weblogs | Forums

Need help interpreting FK error

Hi experts, when I try to delete from tblCSCBookingDocument, I get this error:

The DELETE statement conflicted with the REFERENCE constraint "FK_tblCSCBookingDocumentSelections_tblCSCBookingDocument". The conflict occurred in table "dbo.tblCSCBookingDocumentSelections", column 'CSCBookingDocumentID'.

This is what the constraint looks like:
ALTER TABLE [dbo].[tblCSCBookingDocumentSelections] WITH CHECK ADD CONSTRAINT [FK_tblCSCBookingDocumentSelections_tblCSCBookingDocument] FOREIGN KEY([CSCBookingDocumentID])
REFERENCES [dbo].[tblCSCBookingDocument] ([CSCBookingDocumentID])

Does this mean there are CSCBookingDocumentID values in tblCSCBookingDocument that do not exist in tblCSCBookingDocumentSelections?
How can I resolve Thanks

Did you try any solutions from here?

1 Like

Thanks, @mike01 I have not tried the Cascade option, just a bit afraid of it. I have tried deleting from the other table first and I get the same error on the same exact FK.
I mapped out the FKs and their Dependency Levels.


Does this mapping help at all?
Thanks again.

In this case, you might prefer to use SET NULL rather than CASCADE.