Sunday, 8 July 2012

sql - Check length of a string


Length of VARCHAR fields the function LEN(varcharfield) is useful.
Length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field.
Example:
SELECT LEN(yourvarcharfield) AS VarcharFieldSize
SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize

No comments:

Post a Comment