DATALENGTH function [System]

Function

Returns the length of the expression in bytes.

Syntax

DATALENGTH ( expression )

Parameters

expression The expression is usually a column name. If the expression is a string constant, it must be enclosed in quotes.

Usage

Table 5-14 lists the return values of DATALENGTH.

Table 5-14: DATALENGTH return values

Data type

DATALENGTH

SMALLINT

2

INTEGER

4

DOUBLE

8

CHAR

Length of the data

BINARY

Length of the data

Example

The following statement returns the value 35, the longest string in the company_name column.

SELECT MAX( DATALENGTH( company_name ) )
FROM customer

Standards and compatibility

See also

“CHAR_LENGTH function [String]”

“COL_LENGTH function [System]”