Last post May 19, 2015 02:35 AM by Fei Han - MSFT
May 18, 2015 05:47 PM|rubik951|LINK
I have an Orders table and OrderLines table.
For each order I have a couple of lines which suppose to be connected by having the same OrderID in both tables.
When I am trying to insert the data, it's says that it's cannot be because it has the same foreign key on couple of rows.
How I can do it ?
Thanks in Advance.
May 18, 2015 05:59 PM|AZMatt|LINK
Any time you insert to a table, all of the "key" fields (weather primary or foreign) need to be unique. You can't do two or more inserts with the same foreign key combination.
You will need to post some table definitions and code samples in order to give you any specific advice.
May 19, 2015 02:35 AM|Fei Han - MSFT|LINK
Thanks for your post.
You could refer to below sample to design your tables.
We could add a record with the same “OrderID” into [OrderLines].
If insert a record which “OrderID” is not in [Orders] into [OrderLines], we will get the below error.