• The short answer is NO!

    The long answer is that the easiest way to get the appropriate structure in your XML documents using T-SQL is by using nested queries. Using this approach, it is also easy to set up your nested queries so that they correspond quite well to the structure of your XML documents.

    It is possible to get XML documents with the correct structure without using subqueries. The RAW and AUTO options allow you to use queries that are relatively simple to read, but they give you limited control over the format of your XML document. The EXPLICIT option gives you tons of control, but is a major pain to set up correctly, and is very difficult to read because of all the extraneous calculations necessary to set it up to give you the correct output.

    The best way to approach understanding queries that produce XML documents is to comment out all of the subqueries, executing the resulting query, and looking at the resulting XML document. Then uncomment another section and repeat.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA