• Toreador (5/17/2011)


    Koen Verbeeck (5/16/2011)


    And the explanation doesn't mention why inserting NULL in another string doesn't result in NULL, but in an empty space instead.

    That's what got me.

    Surely it's a bug?

    select 'Vinay, ' + NULL + ', Amit'

    returns NULL, so I'd have thought

    select STUFF('Vinay, Vijay, Amit',8,5,NULL)

    should do the same?

    That's what got me, too.

    I thought concatenating NULL would yield NULL,

    but it seems like it applies Coalesce(..., '') or IsNull(..., '') to the last argument before concatenating it. This behavior is not consistent with that of CharIndex(expression1 ,expression2 [ , start_location ]), for example, which returns NULL if any of the arguments IS NULL.