| | |
foreign key problem
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi, I am new.
I have two table like this
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...
I have two table like this
MS SQL Syntax (Toggle Plain Text)
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... Last edited by bozkurt; Apr 16th, 2009 at 1:01 am. Reason: font character
HI, Hope the below link will help you a lot.
http://support.microsoft.com/kb/321843
http://support.microsoft.com/kb/321843
Last edited by mail2saion; Apr 16th, 2009 at 1:49 am.
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
You can use triggers as said in the KB.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Apr 2009
Posts: 4
Reputation:
Solved Threads: 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
Can anybody have an idea?
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
MS SQL Syntax (Toggle Plain Text)
ALTER TABLE blabla ADD CONSTRAINT blabla FOREIGN KEY (blabla,blabla) REFERENCES blabla(blabla,blabla) ON UPDATE NO ACTION ON DELETE NO ACTION
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?
Logically you need to update the two columns of table2 when the primary key of table1 changes?
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- Foreign key constraint fails (MySQL)
- key problem (MySQL)
- Problem with $_GET and JOIN (PHP)
- Varchar field as foreign reference (MySQL)
- I am getting problem with Foreign Key (MySQL)
- chicken and egg problem (MS SQL)
- change primary key (MS SQL)
- Problem with create script (MySQL)
Other Threads in the MS SQL Forum
- Previous Thread: Stored Procedure for Insert,Update and Delete
- Next Thread: SQL query
| Thread Tools | Search this Thread |






