Solved

Got error creating a FK

Posted on 2011-03-10
7
166 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 39

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 39

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now