Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL FOREIGN KEY conflict help! Expand / Collapse
Author
Message
Posted Saturday, May 4, 2013 3:15 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, May 5, 2013 7:10 AM
Points: 4, Visits: 12
I have two tables and I keep getting an FK conflict error on some of the data being inserted and cannot work out why!




Post #1449471
Posted Saturday, May 4, 2013 6:23 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, August 7, 2014 7:16 AM
Points: 811, Visits: 1,161
Because you have made foreign key as MatchID, where as it should be Venue ID.

CONSTRAINT fk_VenueID FOREIGN KEY (MatchID)

It should be :-

CONSTRAINT fk_VenueID FOREIGN KEY (VenueID)

You create 10 rows for Venue table so after. SO there are 1-10 venue id and when you try to insert 11th row in Match table, you get FK violation error.

Post #1449481
Posted Sunday, May 5, 2013 3:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, May 5, 2013 7:10 AM
Points: 4, Visits: 12
Thank you very much, that has solved that problem but also created another which probably needs a similar fix!

When I try to insert data into my MatNat table, it only does the first 10 and ignores everything after!
Post #1449502
Posted Sunday, May 5, 2013 5:18 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, August 7, 2014 7:16 AM
Points: 811, Visits: 1,161
What error it is giving. You have given data for only MatNat table, so I can't replicate it.
But Check the value of Hotel, Nation & Match Table to see if the value exists in these tables what you are trying to insert.

Post #1449504
Posted Sunday, May 5, 2013 5:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, May 5, 2013 7:10 AM
Points: 4, Visits: 12
Have Pm'ed you
Post #1449505
Posted Sunday, May 5, 2013 5:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, May 5, 2013 7:10 AM
Points: 4, Visits: 12
Thanks!
Post #1449506
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse