Solved

Got error creating a FK

Posted on 2011-03-10
7
171 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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