Tuesday, July 08, 2014

Find column exists in SQL database (COL_LENGTH)

COL_LENGTH

It is a built in function, which returns the length in bytes of the column.

COL_LENGTH('Table_Name','Column_Name')

Table_Name: Name of the table for which column length info required, it is nvarchar type expression.
Column_Name: Name of the column who's length is required, it is also nvarchar type expression.

It returns NULL on error or if users do not have permission to view object.