how to set foriegnkey
Hii...plz help me how to set foriegn key.I have two table named "TB_Employee" and "TB_EmployeeId" in that i have one column "TagId" which i want to set as foriegn key.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ShankeyPosted Nov 24, 2010, 12:53 AM
Hope this is in sql server then do following to create fk in TB_EmployeeId
ALTER TABLE
TB_EmployeeIdADD CONSTRAINT fk_TagID FOREIGN KEY(TagId) REFERENCES TB_Employee (TagId)
Manikavelu VelayuthamPosted Nov 24, 2010, 12:50 AM
Table CUSTOMER
Table ORDERS
CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date datetime,
Customer_SID integer references CUSTOMER(SID),
Amount double);
ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);