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.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Manikavelu VelayuthamRank #413 · 6K reputationPosted Nov 23, 2010, 7:50 PM EST
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);
ShankeyRank #972 · 2.1K reputationPosted Nov 23, 2010, 7:53 PM EST
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)