Hugo Kornelis (10/4/2010)
tommyh (10/4/2010)
Well if one wants to be picky it does return the nr of bytes needed to represent the data. Hence why
select datalength(N'hi'), datalength('hi')
gives 2 different results. 4 vs 2. Because Unicode requires double the space.
That is what I intended to say, but apparently didn't bring across.
DATALENGTH returns the length (in bytes) of the storage for the actual data. For Unicode, that is 2 bytes per character. The seperate storage of the length is not included, since this is not part of the actual data.
I almost thought that (probably me missing something in translation that every native english speaker would get right away). But since it left me confused i thought id might try to add a bit of more clarification (or confusion).
/T