NOT NULL Constraint In SQL

In this article I am going to explain about NOT NULL Constraint in SQL.
  • 2399

Introduction

The NOT NULL constraint in SQL Server enforces a column "not" to accept NULL values.

In this constraint, the field  always has to contain a value. A new record cannot be inserted, or updated a record without adding a value to this field.

The following SQL here, enforces the "P_Id" column and the "LastName" column not to accept NULL values

Example

Suppose we create table named "Persons" and the column names are: P_ID, LAST NAME, FIRST NAME,ADDRESS AND CITY. So here, the P_ID and the LASTNAME will have the NOT NULL values.

NOTNULL_constraint-in-sql.jpg


© 2020 DotNetHeaven. All rights reserved.