SQL: Do you really know how LEN works in T-SQL?
I’ve never liked how the LEN function works in T-SQL for SQL Server.
To test out what others thought, I recently posted a short quiz on my social networks. Here’s the question:
What would you expect the output from this query to be?
DECLARE @Value1 varchar(10) = 'Hello ';
DECLARE @Value2 varchar(10) = 'There ';
SELECT LEN(@Value1), LEN(@Value2), LEN(@Value1 + @Value2);
Nothing tricky. The first value has 3 trailing spaces. The second value has one.
Then I gave the following answer options:
2026-09-03