How To Set Foregin Key

Mar 13, 2007

I've two table.

Table
-------
stu(stuid primary key,name)=======> First table

con(one primary key,two,three,stuuid)=====> Second Table

I need second table(con) Foreign key(stuuid)....

I want stuuid this field Foreign key......

Once insert the value into first table(stu)

Automatically update stuuid this field value..

How to i'll get.* simply stuid,stuuid this two field value are equal *

Any Alter query...........

Plz help me.........

View 4 Replies


ADVERTISEMENT

How Can A Foregin Key Reference Multiple Coulmns Of Clustered Key

Sep 25, 2007



Hi there...

Sounds like a veryy silly question but I somehow got stuck with this & cant think anymore

Basically, I have got a table 'Order_Product' with Clustered Primary Key of columns 'Order_Number' & 'Product_Id'.
I am creating a new table Order_Discussion' with column 'Product', which is a Foreign Key & should reference 'Order_Number' & 'Product_Id' of table 'Order_Product'.

I am trying something like..

Create Table Order_Discussion (
Discussion_Id int,
Product int Foreign Key References Order_Product(Order_Number, Product_Id)
)

but its giving error..
More than one key specified in column level FOREIGN KEY constraint, table 'Order_Discussion'.

Any help will be greatly appreciated.
Cheers!!

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved