Home >Database >Mysql Tutorial >How to Resolve SQL Server's FOREIGN KEY Constraint Error 547 During INSERT?
Solving SQL Server INSERT Errors: FOREIGN KEY Constraint Violation (Error 547)
Error 547 in SQL Server, a FOREIGN KEY constraint violation, arises when an INSERT statement attempts to add a record to a child table (like dbo.Sup_Item
) referencing a non-existent key in the parent table (dbo.Sup_Item_Cat
).
The error message often points to the problematic column and value. For instance, if the error cites client_id
with value '123123', this indicates '123123' is missing from the primary key column of dbo.Sup_Item_Cat
.
To pinpoint the problem, execute sp_help 'dbo.Sup_Item_Cat'
in SQL Server Management Studio (SSMS). This command displays the primary key and the foreign key relationships, helping you identify inconsistencies between the parent and child tables.
The solution involves ensuring data integrity. Before inserting new records into dbo.Sup_Item
, confirm that the corresponding client_id
(or other foreign key values) already exist as primary keys in dbo.Sup_Item_Cat
. Correct any discrepancies to maintain referential integrity.
The above is the detailed content of How to Resolve SQL Server's FOREIGN KEY Constraint Error 547 During INSERT?. For more information, please follow other related articles on the PHP Chinese website!