SQL Server tutorial part 6 - Check constraints


Definition

Check Constraint is used to limit range that can be placed in a column

Check Constraint Column level

Create Table UserDetails(
DetailId int,
Username Varchar(100),
Gender char(1) Constraint user_gender check(Gender in ('M', 'F'))
--Will allow to enter either 'M' or 'F' in gender column
)

Check Constraint Table level

Create Table UserDetails(
DetailId int,
Username Varchar(100),
Gender char(1),
Fees numeric(8,2),
Constraint user_fees Check(Fees >= 500)
)

Please donate and support at https://www.paypal.me/Rajcoomar

Comments

Popular posts from this blog

Car Wash System vb.net

Face recognition using EmguCV 3.0 and typing pattern recognition

Student Information System - AngularJS , ASP.NET API, C#