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. It can be of any datatype. expression is usually a column name. If expression is a character constant, it must be enclosed in quotes.

Examples

Example 1

select Length = datalength(pub_name) 
from publishers

Length     
-----------
         13
         16
         20

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

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute datalength.

See also

Functions char_length, col_length