DATALENGTH VARCHAR in SQL Server -
according msdn storage size of varchar data type actual length of data entered + 2 bytes. i'm trying understand why when run query:
declare @varchar varchar(40) = 'racing club de avellaneda' select datalength(@varchar) bytes, len(@varchar) characters;
the storage size of @varchar same char data type, it's 25 , not 27 (25+2).
does has datalength function?
datalength tell number of bytes of data, doesn't include 2 bytes precede data in storage. 2 byte overhead of varchar recording number of bytes in string - i.e. in case 25