Thursday, October 2, 2014

Set table column value as mandatory

Hi Pakojones,


According to your description, you want to specify a value for a column as mandatory value, right?


In this case, we can use the CHECK Constraints. CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns. Here is a sample query for your reference.



CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CONSTRAINT chk_Person CHECK (City='Sandnes')
)

Regards,



Charlie Liao

TechNet Community Support



No comments:

Post a Comment