tsql - Transact Sql LEFT function weird output -


select replace(stuff('123456',2,2,'abcd'),'1',' ')  select left('abcd456',4)  select left(replace(stuff('123456',2,2,'abcd'),'1',' '),4) 

ok first select outputs 'abcd456', series of functions evaluates first parameter left function in second select second select returns 'abcd' expected third select returns 'abc'

why? shouldn't output 'abcd'? know? in advance.

it clearer if do

select '[' + left(replace(stuff('123456',2,2,'abcd'),'1',' '),4) + ']' 

which returns

[ abc] 

there leading space!

select stuff('123456',2,2,'abcd') gives 1abcd456

then replace 1 space


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

visual studio - Deleting lines of code in a text editor -

What's the encoding type of Android 2.2 push message? -