There is a bit difference between
char and varchar[
^] data types:
char [ ( n ) ]
Fixed-length, non-Unicode character data with a length of n bytes. n must be a value from 1 through 8,000. The storage size is n bytes. The SQL-2003 synonym for char is character.
varchar [ ( n | max ) ]
Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The SQL-2003 synonyms for varchar are char varying or character varying.
So, when you use
LEN[
^] function, it returns the number of characters of the specified string expression,
excluding trailing blanks, which means:
LEN(@FirstName + ' ' + @LastName)=28
, because trailing blanks of
@FirstName
are not cutted,
' '
(space) length is equal to 1 and length of
@LastName
is equal to 7 (trailing blanks are removed)!
The statement:
LEN(@FirstName + ' ' + @LastName)
is not equal to:
LEN(@FirstName) + LEN(' ') + LEN(@LastName)