check constraint prevents duplicate values in a table code example
Example 1: check constraint prevents duplicate values in a table
CREATE TABLE sampleTable ( col1 int NOT NULL, col2 varchar(10) NOT NULL, nonUniqueColumn varchar(5) NULL, CONSTRAINT UC_nameOfConstraint UNIQUE (contestID,keyName) );
Example 2: check constraint prevents duplicate values in a table
CONSTRAINT UC_nameOfConstraint UNIQUE (column1,column2)