SQL Not NULL constraint ensures
the columns cannot have NULL value and if you insert or update NULL value to
this column, it throws exception
Cannot
insert the value NULL into column 'StatusCode', table 'dbo.OrderStatus'; column
does not allow nulls. INSERT fails.
Syntax: Create NOT NULL constraint on
Create Table
The below SQL will create a NOT NULL constraint on StatusCode Column
Create Table OrderStatus
(
StatusID int IDENTITY(1,1) NOT NULL,
StatusCode varchar(3) NOT NULL,
StatusDescription varchar(50),
CONSTRAINT [OrderStatus_PK] PRIMARY KEY CLUSTERED ( StatusID ASC),
)
No comments:
Post a Comment