February 1, 2010 at 10:37 am
Hello all,
I am getting this error and I'm not sure why, could someone shed some light on it?
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK_SODetail_SOHeader". The conflict occurred in database "ReportingDB", table "dbo.SOHeader", column 'OrderId'.".
Thanks for any help or advice!
February 1, 2010 at 10:39 am
marty.seed (2/1/2010)
Hello all,I am getting this error and I'm not sure why, could someone shed some light on it?
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK_SODetail_SOHeader". The conflict occurred in database "ReportingDB", table "dbo.SOHeader", column 'OrderId'.".
Thanks for any help or advice!
It's because you're trying to insert some data that has some kind of conflict with your foreign key. For example, if your index is set up for unique records, you can't enter "foo" if "foo" already exists.
I can't tell you anything more without seeing some sample data.
+--------------------------------------------------------------------------------------+
Check out my blog at https://pianorayk.wordpress.com/
February 1, 2010 at 10:54 am
That helps Ray! Thank you, I will look through the data and see whats up.
February 1, 2010 at 11:30 am
You're welcome! 🙂
+--------------------------------------------------------------------------------------+
Check out my blog at https://pianorayk.wordpress.com/
February 3, 2010 at 4:25 am
You are attempting to add a record to a child table that does not have a corresponding value in the parent table as defined in the Foreign Key.
The error message tells you the column "Order_ID", simply query the parent table for the value that you are attempting to INSERT into the child Table.
You can only define a relation to the parent table to the Priimary Key or Unique Constraint(s).
You may query the following system tables and file on table name and column name to view information on the FK Contraint:
sys.foreign_keys
sys.foreign_key_columns
sys.objects
You may also use SMSS to view information about your constraint.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
February 3, 2010 at 7:47 am
Hi Welsh, this helped immensely, thank you
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply