Returns the actual length, in bytes, of the specified column or string.
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.
select Length = datalength(pub_name) from publishers
Length ----------- 13 16 20
Finds the length of the pub_name column in the publishers table.
datalength, a system function, returns the length of expression in bytes.
datalength finds the actual length of the data stored in each row. datalength is useful on varchar univarhcar, varbinary, text and image datatypes, since these datatypes can store variable lengths (and do not store trailing blanks). When a char or unichar value is declared to allow nulls, Adaptive Server stores it internally as varchar or univarchar. For all other datatypes, datalength reports their defined length.
datalength of any NULL data returns NULL.
SQL92 – Compliance level: Transact-SQL extension.
Any user can execute datalength.
Functions char_length, col_length