O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required