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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -