Sometimes it's necessary to know the length of a data column in SQL Server especially when you are working with variable length types such as varchar and text. To do this you can use simply DATALENGTH function in SQL Server. This function is used as follows:
and the parameter is an expression of any data type. This function is especially useful with varchar, varbinary, text, image, nvarchar, and ntext data types because these data types can store variable-length data. Also note that the DATALENGTH of NULL is NULL.
To read more about this subject visit the following page: