Example of CHECK constraint in SQL server-
CREATE TABLE Students (ID INT NOT NULL, FirstName VARCHAR(200),Fees INT CHECK (Fees>0));
Naming of CHECK constraint in SQL server during creation of table-
CREATE TABLE Students (ID INT NOT NULL, FirstName VARCHAR(200), Fees INT , Age INT ,
CONSTRAINT chk CHECK (Fees>0 AND Age>21)); –constraint named as chk
CHECK constraint creation on existing table-
ALTER TABLE Students
ADD CHECK (Age>21);
Naming of CHECK constraint in SQL server on existing table-
ALTER TABLE Students
ADD CONSTRAINT chk CHECK (Fees>0 AND Age>21);
DROP a CHECK constraint-
ALTER TABLE Students
DROP CONSTRAINT chk;