Home > DeveloperSection > Forums > SQL NOT NULL Constraint
Ankit Singh

Total Post:341

Posted on    November-03-2015 10:00 PM

 .NET SQL Server 

 1 Reply(s)
 288  View(s)
Rate this:
what is   NOT NULL Constraint in sql server .

aditya kumar Patel

Total Post:250

Posted on    November-03-2015 10:15 PM

The NOT NULL constraint enforces a column to NOT accept NULL values.

The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field.

The following SQL enforces the "U_Id" column and the "LastName" column to not accept NULL values:



U_Id int NOT NULL,

LastName varchar(255) NOT NULL,

FirstName varchar(255),

Address varchar(255),

City varchar(255)


--when we want insert null value lastname get error

insert into Users(U_Id,LastName,FirstName,Address,City)



When I insert lastname null get error.

Result :

Don't want to miss updates? Please click the below button!

Follow MindStick