Can we give or assign more than one column a Check Constraint?

 Posted by vishalneeraj-24503 on 9/1/2014 | Category: Sql Server Interview questions | Views: 988 | Points: 40

Yes.We can provide check constraints on multiple columns as shown below example:
Create Table Employee_Master

Employee_Id int not null,
First_Name varchar(100) not null,
Middle_Name varchar(100),
Last_Name varchar(100) not null,
Employee_Name varchar(100) not null,
PAN_Number varchar(10) not null,
LDAP varchar(10) not null,
Check ([Employee_Id] > 0
And [PAN_Number] Is Not Null
And [LDAP] Is Not Null)

Here,Check Constraints are applied on Employee_Id,Pan_Number and LDAP columns which says that employee id must be greated than zero(0) and
PAN number and LDAP column can not have Null values.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response