RAW Mode
When specified at the end of a SELECT
statement, the keywords FOR XML RAW
tell SQL Server to generate a one-XML-element-per-row structure. The FOR XML
statement has a few options that change its output from the default of document fragments to well-formed documents with a slightly (compared to a few other FOR XML
options) reshaped structure. This is its syntax:
FOR XML RAW [ ('ElementName') ][[ , BINARY BASE64 ][ , TYPE ][ , ROOT [ ('RootName') ]][ , { XMLDATA | XMLSCHEMA [ ('TargetNameSpaceURI') ]} ][ , ELEMENTS [ XSINIL | ABSENT ] ]
Listing 49.1 illustrates the XML generated by the no-option version of FOR XML RAW
. (Note that all the code in this chapter relies on the AdventureWorks2012
sample database.) ...
Get Microsoft® SQL Server 2012 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.