COL_LENGTH function is used to get defined length of a column in bytes.
Syntax of COL_LENGTH Function :
COL_LENGTH ( 'table' ,'column' )
table is a name of a table for which to get column length. It is of type nvarchar.
column is a name of the column for which to get length. It is of type nvarchar.
Return type of COL_LENGTH function is an integer.
Examples of COL_LENGTH Function :
Example 1 : Use of COL_LENGTH function in select clause
SELECT COL_LENGTH('Customers','ContactName')
Output
510
Above example returns length of column ContactName of Customers table in bytes where ContactName is of type nvarchar(255).