• Firstly, I couldn't get the code to run from the article - as it's different from the code in the resource section!

    But more importantly I think you're missing the point about xml in SQL Server. With For Xml, Path, query. etc. you don't have to resort to string building to construct your xml documents. The code you've supplied could be rewritten much more simply and clearly. (At least, that's my initial feeling.)

    Sorry to be negative - hopefully you'll take it as an encouragement to explore the tools available.

    Regards,

    David McKinney.