How does SQL Server handles Spaces in Substring/LEFT?
If there’s a SPACE where at the Substring/Left cutoff, I get a different value than if there’s text.
Is there documentation for this?
DECLARE @st_Spaces char(25)
DECLARE @st_NoSpaces char(25)
SET @st_Spaces = '123 56' --One space, pos 4
SET @st_NoSpaces = REPLACE(@st_Spaces, ' ', '4') --Replace space w/ 4
SELECT LEN(LEFT(@st_Spaces, 4)), --Returns 3
LEN(LEFT(@st_NoSpaces,4)) --Returns 4
It’s right there in the documentation for LEN.