Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Error quotes a non-existent FK constraint!

Author  Topic 

David Anderson
Starting Member

8 Posts

Posted - 2012-11-13 : 06:33:21
I tried to create a new database diagram (with modified relationships) in one of my databases but got the following error message when I tried to save it.

'Entries' table
- Unable to create relationship 'FK_Entries_EntrySummary'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Entries_EntrySummary". The conflict occurred in database "sie-test", table "dbo.EntrySummary".

My problem is that I cannot find a FK constraint called "FK_Entries_EntrySummary" in my Entries table! It's not in the EntrySummary table either. Can anyone explain what might be happening here?

David

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-11-14 : 06:52:45
The error message is referencing the constraint you are trying to make...which is named "FK_Entries_EntrySummary", and it can't be created probably because there are some values in the EntrySummary table that doesn't comply with it.

Look in the EntrySummary table and see if you have any values there that are not present in the Entry-table.

- Lumbago
My blog-> http://thefirstsql.com
Go to Top of Page

David Anderson
Starting Member

8 Posts

Posted - 2012-11-14 : 07:29:56
Hi Lumbago,
You are absolutely correct! There were 3 very old orphaned records in my Entries table for which there was no matching record in the EntrySummary table. It just never occurred to me that the FK constraint causing the error was a new one I was trying to make. I just assumed the error referred to an existing constraint.

Problem now solved. Many thanks for your help!

David
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-11-14 : 08:37:38
Excellent :)

- Lumbago
My blog-> http://thefirstsql.com
Go to Top of Page
   

- Advertisement -