DATALENGTH function [System]

Function

Returns the length of the expression in bytes.

Syntax

DATALENGTHexpression )

Parameters

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

Usage

Table 4-15 lists the return values of DATALENGTH.

Table 4-15: 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 Customers

Standards and compatibility

See also

“CHAR_LENGTH function [String]”

“COL_LENGTH function [System]”