Returns the actual length, in bytes, of the specified column or string.
datalength(expression)
select Length = datalength(pub_name) from publishers
Length ----------- 13 16 20
datalength returns the uncompressed length of a large object column, even when the column is compressed.
select datalength(ut) from unitable ------------- 8
datalength finds the actual length of the data stored in each row. datalength is useful on varchar, univarchar, 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, the SAP ASE server stores it internally as varchar or univarchar. For all other datatypes, datalength reports the defined length.
datalength accepts the text_locator, unitext_locator, and image_locator LOB datatypes.
datalength of any NULL data returns NULL.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute datalength.