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

Remarks

DATALENGTH return values

Data type

DATALENGTH

SMALLINT

2

INTEGER

4

DOUBLE

8

CHAR

Length of the data

BINARY

Length of the data

Standards and Compatibility

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

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

Example

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

SELECT MAX( DATALENGTH( company_name ) )
FROM Customers
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]