Skip to content
 

Add Foreign Key

To Add a foreign key to a column in an existing table, use ALTER TABLE ADD CONSTRAINT

ALTER TABLE dbo.President_Lookup
ADD CONSTRAINT fk_PresidentID
FOREIGN KEY (PresidentID)
REFERENCES dbo.Presidents (PresidentID)


Popular search terms:

2 Comments

  1. sanket says:

    I have 1 query.
    I have 2 tables, one is master and another is normal table.
    the primary key of one table is used in 2nd table…
    bt I dont know, how I can set that key will foreign..????
    please send mi feedback on my email…
    or give mi an example code for setting foreign key…

  2. Anonymous says:

    THIS IS NOT WORKING

post a comment OR Post Your Question on our ASK! Community!