sql - Does the LEN() function internally apply TRIM()? -


dooes sql len() function internally trim() data prior calculating length of string?

example:

declare @a varchar(max), @b varchar(max) set @a = '12345 ' set @b = '12345 7'  select @a, len(@a) -- 12345    5  select @b, len(@b) -- 12345 7  7 

both @a , @b have 7 characters. @a has 5 numeral characters , 2 spaces @ end.

when copying both results results window, can see both variables have length of 7 chars. when trying find length of variables using len() differs. same thing happens while storing data in table varchar column.

it excludes trailing blanks

according len (transact-sql)

"returns number of characters of specified string expression, excluding trailing blanks."

also similar questions

why t-sql's len() function ignore trailing spaces?

len function not including trailing spaces in sql server


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -