DATALENGTH Function [System]

Returns the length of the expression in bytes.

Syntax

DATALENGTHexpression )

Parameters

Parameter

Description

expression

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

Returns

UNSIGNED INT

Usage

DATALENGTH return values

Data type

DATALENGTH

SMALLINT

2

INTEGER

4

DOUBLE

8

CHAR

Length of the data

BINARY

Length of the data

Example

Returns the value 35, the longest string in the company_name column:

SELECT MAX( DATALENGTH( company_name ) )
FROM Customers

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Adaptive Server Enterprise function implemented for Sybase IQ.

Related reference
BIT_LENGTH Function [String]
BYTE_LENGTH Function [String]
CHAR_LENGTH Function [String]
COL_LENGTH Function [System]
LEN Function [String]
LENGTH Function [String]
OBJECT_NAME Function [System]
OCTET_LENGTH Function [String]
STR_REPLACE Function [String]