• LutzM (4/14/2010)


    Maybe this link will be of some help, too:

    http://www.sqlservercentral.com/Forums/Topic679572-338-2.aspx

    Barry did a great job explaining how the STUFF ... FOR XML PATH actually works.

    SQLRNNR (4/15/2010)


    Here is another excellent article on Stuff and For XML

    http://www.sqlservercentral.com/articles/Test+Data/61572/

    Innocently but blatantly hijacking this thread, it is coincidental that I was recently searching for an article on FOR XML PATH, running across both of these excellent explanations.

    However I was looking for a bit more. Specifically, I'm wondering if anyone knows of an article that not only explains how it works and also gives examples that adds the special handling for when the content of the column contains one of the restricted characters? I recently saw someone post a performance comparison of the "standard" approach next to the one with special character handling, and I can't even find that at the moment.

    It seems that all of the ones I've run across either show it without special character handling or with, and only Jeff's examines the performance.

    If the article explained performance as well it would be a bonus. Thanks.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St