DF189: Explicit length is not specified for varying-length character data type.

Last modified: December 25, 2024

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

Category

BEST PRACTICE

Message

Explicit length is not specified for varying-length character data type.

Description

It is recommended to explicitly specify data length to prevent data truncation errors.

Noncompliant code example

CREATE TABLE dbo.DemoTable(code VARCHAR NOT NULL)
GO

Compliant solution

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