Difference between revisions of "Creating tables in SQL Server"

From MyWiki
Jump to: navigation, search
(Created page with "Alter table table1 add constraint <name of constraint> <br> FOREIGN KEY (<column>) references table2 (<primary key column>)<br>")
 
Line 1: Line 1:
 
Alter table table1 add constraint <name of constraint> <br>
 
Alter table table1 add constraint <name of constraint> <br>
 
FOREIGN KEY (<column>) references table2 (<primary key column>)<br>
 
FOREIGN KEY (<column>) references table2 (<primary key column>)<br>
 +
 +
Foreign constraint prevents invalid data from being entered into the foreign key column. The foreign key value must be one of the values contained in the table it references.

Revision as of 00:41, 3 September 2015

Alter table table1 add constraint <name of constraint>
FOREIGN KEY (<column>) references table2 (<primary key column>)

Foreign constraint prevents invalid data from being entered into the foreign key column. The foreign key value must be one of the values contained in the table it references.