Using Checks

Using Checks

One of the handy tools regarding the constraint in SQL Server is check.
This simple, but powerful, tool allows us to use column based constraints on the data.
Say you have a table with age column. If you want to add constraint on age for values less than or equal to zero and above 100 – thinking we would live 100 years…
ALTER TABLE tbl ADD CONSTRAINT age_constraint CHECK(age < 100);
That is all.
If I try to run a query like this..
INSERT INTO tbl (age,..) VALUES (-12);
Then the engine would tell me that this cannot happen.

find longest word in the sentence

Get maximum occurring character

Flatten nested javascript array

Implement Queue Using two Stacks – JavaScript algorithm

Update Node and npm on mac OSX

Tunneling to AWS instance using pem file

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*