DF007: The length of the datatype is not specified.

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

Category

BEST PRACTICE

Message

The length of the datatype is not specified.

Description

It is recommended to explicitly specify the length of the (N)VARCHAR, VARBINARY, (N)CHAR, BINARY, DECIMAL, and NUMERIC datatypes in the CAST and CONVERT clauses.

Additional information

It is an optional integer used to specify the length of the target data type, specifically for data types that allow user-defined lengths.

Noncompliant code example

SELECT CAST(FirstName as varchar) AS FirstName
FROM dbo.Customers

Compliant solution

SELECT CAST(FirstName as varchar(128)) AS FirstName
FROM dbo.Customers

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?