SQL Server: The INSERT statement conflicted with the FOREIGN KEY constraint 'x'. (Msg 547)

The row references a parent that doesn’t exist (or a DELETE would orphan children).

Seen on: SQL

Meaning

Msg 547 covers FK and CHECK conflicts for INSERT, UPDATE and DELETE. The message names the table and column.

Common causes

  • Parent row missing
  • Deleting a referenced parent
  • CHECK constraint violation

⚡ Quick fix

  1. Insert parents first
  2. Delete or reassign children
  3. Use ON DELETE CASCADE where appropriate

Detailed fix by platform

SQL

  1. SELECT * FROM dbo.Customers WHERE Id = 42;

How to diagnose

  1. Constraint — Which one and which column?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.