FOR XML Commands
SQL Server supports an enhancement to the T-SQL syntax that enables normal relational queries to output their result set as XML, using any of these four approaches:
FOR XML RAW
FOR XML AUTO
FOR XML EXPLICIT
FOR XML PATH
The first three of these options were introduced with the very first XML support in SQL Server 2000. We’ll start with these options and then cover later XML enhancements added in SQL Server 2008, which includes the fourth option (FOR XML PATH).
FOR XML RAW
FOR XML RAW produces attribute-based XML. FOR XML RAW essentially creates a flat representation of the data in which each row returned becomes an element and the returned columns become the attributes of each element. FOR XML RAW also doesn’t interpret joins in any ...
Get Programming Microsoft® SQL Server® 2012 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.