SQL Server Error 547 — The statement conflicted with the FOREIGN KEY constraint
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_X". The conflict occurred in database "Y", table "dbo.Z", column 'W'.
You tried to insert/update a row referencing a parent value that doesn't exist, or delete a parent row that child rows still depend on. The same error number also covers CHECK constraint violations, so read the message carefully — it names which constraint fired.
Common causes
- Inserting a child row (e.g. an order) before its parent row (e.g. the customer) exists
- Deleting a parent row without first deleting or reassigning its child rows
- Application inserting foreign keys from stale cached data (the referenced row was deleted since)
- A CHECK constraint rejecting a value outside its allowed range (same error number, different constraint type)
How to fix it
- Read the message for the exact constraint and column named — it tells you which relationship failed.
- For inserts: confirm the parent row exists first, or fix insert ordering in the application/transaction.
- For deletes: either cascade the delete (ON DELETE CASCADE, used carefully) or explicitly remove/reassign child rows first.
- For CHECK constraint hits: validate the incoming value against the constraint definition (sys.check_constraints) before writing.
Paste your full error and the statement here for a fix specific to your schema.
Try error explainer free →