unable to add foreign key
Posted on 2011-10-12
So I am trying to add a foreign key to a table with three columns
one is an id column (the primary key) and the other two are foreign keys, or at least they are supposed to be. I try adding the last foreign key and i keep getting
Msg 1785, Level 16, State 0, Line 1
Introducing FOREIGN KEY constraint 'fk_id' on table 'tablename' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
However when i do no action i get
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "fk_id". The conflict occurred in database "database", table "dbo.othertable", column 'id'.
It doesn't make sense, because they are both int's and they both have the same range of numbers.
When i use the GUI it says it saved on the 'othertable' but failed on the one that needs the foreign key. Any ideas?