Len() vs datalength() in SQL Server 2005
Be careful. DATALENGTH returns the number of bytes used, not the number of characters.
Be careful. DATALENGTH returns the number of bytes used, not the number of characters.
You can find the number of characters using system function LEN. i.e. SELECT LEN(Column) FROM TABLE
SELECT DATALENGTH(imagecol) FROM table See MSDN
varchars and equality are thorny in TSQL. The LEN function says: Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks. You need to use DATALENGTH to get a true byte count of the data in question. If you have unicode data, note that the value … Read more