Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Foreign Key

Posted on 2013-02-06
2
Medium Priority
?
471 Views
Last Modified: 2013-02-06
ALTER TABLE Curve_W_Sign
ADD CONSTRAINT fk_Curve
FOREIGN KEY (Support_ID)
REFERENCES Asupport_Sign(Support_ID)

Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "fk_Curve". The conflict occurred in database "CNTY_GIS", table "dbo.Asupport_Sign", column 'Support_ID'.


Within my "Child" table i do have duplicates of the ID that are in the Support_Sign table which i thought should be ok? is it? The Parent Table can have multiple ID's in the "Child" Tables right?
0
Comment
Question by:PtboGiser
2 Comments
 
LVL 25

Accepted Solution

by:
jogos earned 2000 total points
ID: 38860502
More foreign keys in your curve_w_sign can point to same primary key in asupport_sign.

But problem will be that there are key's that don't exists.
select * from curve_w_sign  as c
where not exists (select 1 from asupport_sign a where a.support_id = c.support_i)

Open in new window

0
 

Author Closing Comment

by:PtboGiser
ID: 38861192
Thanks for your help!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

916 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