Mark constraint with nocheck when creating a constraint : Check Options « Constraints « SQL Server / T-SQL






Mark constraint with nocheck when creating a constraint

 


4>    CREATE TABLE Customers
5>    (
6>       CustomerNo     int     IDENTITY   NOT NULL
7>          PRIMARY KEY,
8>       CustomerName   varchar(30)        NOT NULL,
9>       Address1       varchar(30)        NOT NULL,
10>       Address2       varchar(30)        NOT NULL,
11>      City            varchar(20)        NOT NULL,
12>      State           char(2)            NOT NULL,
13>      Zip             varchar(10)        NOT NULL,
14>      Contact         varchar(25)        NOT NULL,
15>      Phone           char(15)           NOT NULL,
16>      FedIDNo         varchar(9)         NOT NULL,
17>      DateInSystem    smalldatetime      NOT NULL
18>    )
19>    GO
1>    ALTER TABLE Customers
2>       WITH NOCHECK
3>       ADD CONSTRAINT CN_CustomerPhoneNo
4>       CHECK
5>       (Phone LIKE '([0-9][0-9][0-9]) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]')
6> go
1>
2> drop table Customers;
3> GO

 








Related examples in the same category

1.The syntax of a check constraint: CHECK (condition)
2.Blocking Empty and Missing Character Input
3.WITH CHECK OPTION says any INSERT or UPDATE statements must meet that where clause criteria
4.A statement that creates a table with two column-level check constraints
5.check constraints coded at the table level