Solved

Got error creating a FK

Posted on 2011-03-10
7
172 Views
Last Modified: 2012-05-11
Hi, I'm using sql 2005, sp3.  Please see the attached file for the error screen.  How to fix this?  thanks.
FkError.jpg
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35098762
Are there any missing values in the Primary Key table?
0
 

Author Comment

by:lapucca
ID: 35099902
What do you mean by missing values?  what am I looking for that's missing?  thank you.
0
 

Author Comment

by:lapucca
ID: 35099947
If I remove "Check existing data upon creation" then the FL relationship is saved just fine.  I still like to correct this problem.  What should I check and correct ?  Thanks.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 40

Expert Comment

by:lcohan
ID: 35099960
You should check all values and make sure no duplicates exists then you should be able to add it with check. Check related tables by that column as well for FKeys perspective.
0
 

Author Comment

by:lapucca
ID: 35099985
Do you mean no duplicate rows?  I mean, it's 1 to many so personID is repeated in the history table.  
Can you elaborate on this "Check related tables by that column as well for FKeys perspective." ?  Thanks.
0
 
LVL 40

Accepted Solution

by:
lcohan earned 500 total points
ID: 35100151
Yeah my bad for that...that would be for the PK not FK as you can't add a PK on a table with duplicates..
And of course in a one to many relation you should check following for orphans:
You cant add a 1-many relation if the parent is missing so I would run smthing like:

select id from child_table
except
select id from parent_table

thias will give you the list of all children without parents and you need to
a: delete if possible as orphans
b: find the parent and restore the entry in parent_table.

hope this helps...
0
 

Author Closing Comment

by:lapucca
ID: 35100872
Great, thanks.  Orphan records is the culprit here.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question