datalength

Description

Returns the actual length, in bytes, of the specified column or string.

Syntax

datalength(expression)

Parameters

expression

is a column name, variable, constant expression, or a combination of any of these that evaluates to a single value. expression can be of any datatype, an is usually a column name. If expression is a character constant, it must be enclosed in quotes.

Examples

Example 1

Finds the length of the pub_name column in the publishers table:

select Length = datalength(pub_name) 
from publishers
Length 
-----------
         13
         16
         20

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute datalength.

See also

Functions char_length, col_length