DF190: No nullability constraint is specified for table column.

Last modified: December 25, 2024

The topic describes the DF190 T-SQL code analysis rule.

Category

BEST PRACTICE

Message

No nullability constraint is specified for table column.

Description

It is recommended to explicitly specify the nullability of table columns when creating a table, declaring a temporary table, or defining a table variable.

Additional information

By following this rule, you provide clarity about the expected behavior of the columns regarding null values, which enhances the understanding of the table structure and facilitates data integrity. Additionally, explicitly defining nullability helps prevent potential errors and inconsistencies in data manipulation operations.

Noncompliant code example

CREATE TABLE dbo.DemoTable(Code VARCHAR(128))
GO

Compliant solution

CREATE TABLE dbo.DemoTable(Code VARCHAR(128) NULL)
GO
 
CREATE TABLE dbo.DemoTable(Code VARCHAR(128) NOT NULL)
GO