AUTO
Mode
When RAW
mode is not enough, FOR XML AUTO
provides a few more ways to shape your XML output. Its usefulness derives from its capability to produce nested XML elements from rows derived by joining multiple tables, in contrast to the flat structure of RAW
mode.
The ROOT
keyword introduced earlier also applies with AUTO
mode, and it is good practice to continue to use it in your queries. Like RAW
mode, AUTO
mode produces attribute-centric XML by default, but you can change this by using the ELEMENTS
keyword. XSINIL
and XMLSCHEMA
are also applicable here, having the same effect as with RAW
mode. Listing 47.6 illustrates these points.
With AUTO
mode, the keywords ...
Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.