TSQL: LEN vs DATALENGTH August 2, 2006
Data loving developer/ leader/ product shaper, life-long learner, dog owner, crafter, 30yearsagotoday tweeter, photographer, reader, brightonbloggers administrator, occasional gardener and even more occasional snowboarder
This blog contains random thoughts on random subjects — sometimes about stuff I've made (via craft or code), sometimes my rants and ramblings about a miscellany of things, and sometimes more personal, reflective pieces.
LEN defined in SQL Server Books online as Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks.
DATALENGTH defined as Returns the number of bytes used to represent any expression. DATALENGTH is especially useful with varchar, varbinary, text, image, nvarchar, and ntext data types because these data types can store variable-length data. The DATALENGTH of NULL is NULL.