0

Hi, I am new.
I have two table like this

create table1(
ID VARCHAR(10),
CONSTRAINT PKeyt1 PRIMARY KEY (ID)
)

create table2(
ID1 VARCHAR(10),
ID2 VARCHAR(10)
)

I want to add foreign key to table2 which ID1 and ID2 is different but referenced same column ID and ON UPDATE CASCADE. I tried every way which I now but I get this error


Msg 1785, Level 16, State 0, Line 2
Introducing FOREIGN KEY constraint 'blabla' on table 'blabla' 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 2
Could not create constraint. See previous errors.


How can I do this or can sql do this :)) thanks for reply...

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

No it isnt help to me because I want to add ON UPDATE CASCADE foreach key but in this link used ON UPDATE CASCADE just for one key... Can we do foreach key in mssql?

0

I do that ON UPDATE NO ACTION ON DELETE NO ACTION but I am very bad in trigger Can anybody give simple example for trigger?

0

Thanks for reply I do trigger bu I get error when I update row like this:

The UPDATE statement conflicted with the REFERENCE constraint "blabla". The conflict occurred in database "blabla", table "blabla".

I think my wrong in describing foreign key. I did it like this

ALTER TABLE blabla ADD CONSTRAINT blabla FOREIGN KEY (blabla,blabla) REFERENCES blabla(blabla,blabla) ON UPDATE NO ACTION ON DELETE NO ACTION

Can anybody have an idea?

0

blabla blabla blabla I don't understand anything.
Logically you need to update the two columns of table2 when the primary key of table1 changes?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.