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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Multiple Foreign Keys

Author  Topic 

Bobba Buoy
Starting Member

36 Posts

Posted - 2004-12-30 : 16:25:56
I am having trouble creating multiple foreign keys on a table so that I can set up cascading update and cascading delete from two different primary tables. I am using the diagram to do this but when I try to save the diagram I get the following error.


ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_IndResults_RaceData'. The conflict occurred in database 'VIRA', table 'RaceData', column 'RaceID'.


What would cause this to happen? Is it possible that I have records in the foreign table that do not transfer back to the primary table?

Thanks!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-12-31 : 05:05:18
"What would cause this to happen? Is it possible that I have records in the foreign table that do not transfer back to the primary table?"....YUP


select * from mytable where not exists (select * from racedata a where a.raceid = mytable.mycol)
or
select * from racedata where not exists (select * from fktable a where a.mycol = racedata.raceid)

should help find the affected rows....off the top of my head I don't know/can't figure whether or not the racedata table is the child or parent of the affected relationship.
Go to Top of Page
   

- Advertisement -