• 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 exactly my reaction. The BoL page quoted states that the last expression is inserted in the other, and I'm pretty sure that sticking a NULL in the middle of a string should produce NULL. If it doesn't, I would regard it as a bug unless there were a clear statement in BoL that this operation on NULL was unlike any other in SQL (if there is such a statement, I haven't found it). I wonder if it's affected by the CONCAT_NULL_YIELDS_NULL setting?

    Tom