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? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -