7/27/16

How to foreign key in the two table.Check constraints

ALTER TABLE parentTable1 ADD FOREIGN KEY (parentTable1.Column)
REFERENCES Table2(table2.Column)
Few point- both table columns should have same data type with same length


I am not sure but i think foreign column can not have null value in parent table 


Check constraints

Check constraints is used to limit the Range of the value that can be entered a column. when adding graphically the we have to save table so that constraints will be there.

Unique  constraints

The UNIQUE constraint uniquely identifies each record in a database table.
The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns.
A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it.Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.
there option for seed value which provide the starting value on column then there is option for auto increment also

How to get the last generated identity column value 

using SELECT SCOPE_IDENTITY() in the scope 

No comments: