07-24-14, 09:19 #1Registered User
- Join Date
- Nov 2013
Unanswered: Create foreign key using composite primary key
I am trying to create a FK using a composite PK and here are the details that I want to achieve.
Column A1 not null,
Column A2 not null
Primary key (A1, A2).
Column B1 Primary key.
Column B2 not null
FK (B2) References A(A1).
When I try to do this I am getting some errors. Questions: First of all is this possible? if yes, then how I can create it. Please let me know on the same.
07-24-14, 09:26 #2Annie's Dog Walker
Provided Answers: 6
- Join Date
- Nov 2004
- on the wrong server
if you primary key is a composite, so must be your foreign key. I tend to stay away from composite keys.
ALTER TABLE boo
ADD CONSTRAINT FK_boo_hoo FOREIGN KEY (blah,blah2) REFERENCES blah(blah,blah2)If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry. Earnest Hemingway, A Farewell To Arms.