Advertisement

Latest Post

Saturday, 24 September 2016

How to use NOT NULL in sql server

NOT NULL

This  constraint is used to void the acceptance of null value in the column of the table. by default a column has NULL constraints means that columns can hold the null value.

Example

Following is the example to apply NOT NULL Constraint on CREATE TABLE

CREATE
TABLE Employee
(
Id int NOT NULL CHECK (Id>0),
Name varchar(255) NOT NULL,
Address varchar(255),
Age int,
)



you can also apply NOT NULL constraint on existing table as below query

ALTER TABLE Employee
MODIFY age  INT NOT NULL;

Government Jobs