---
title: "SQL NOT NULL Constraint"  
description: "SQL NOT NULL Constraint"  
author: "Anonymous User"  
published: 2015-11-03  
updated: 2015-11-03  
canonical: https://www.mindstick.com/forum/33564/sql-not-null-constraint  
category: ".net"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# SQL NOT NULL Constraint

what is [NOT NULL Constraint](https://www.mindstick.com/interview/1933/what-is-not-null-constraint) in [sql server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) .

## Replies

### Reply by Anonymous User

The NOT [NULL](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp) [constraint](https://www.mindstick.com/articles/434/constraint-in-sql-server) 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](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) enforces the "U_Id" column and the "LastName" column to not accept NULL values:

```
CREATE TABLE Users
(
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)
 values(1011,null,'Ravi','mumbai','thane') 
```

```
When I insert lastname null get error.Result :
```


---

Original Source: https://www.mindstick.com/forum/33564/sql-not-null-constraint

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
