Databases Reference
In-Depth Information
Figure 7-1. Using FOR XML RAW
How It Works
FOR XML RAW mode produces very “raw” XML. It turns each row in the result set into an
XML row empty element and uses an attribute for each of the column values, using the
alias names you specify in the query as the attribute names. It produces a string com-
posed of all the elements.
FOR XML RAW mode doesn't produce an XML document, since it has as many root ele-
ments ( raw ) as there are rows in the result set, and an XML document can have only one
root element.
Try It Out: Using FOR XML RAW (Element Centric)
To change the formatting from attribute centric (as shown in the previous example) to
element centric, which means that a new element will be created for each column, you
need to add the ELEMENTS keyword after the FOR XML RAW clause as shown in the following
example:
Search WWH ::




Custom Search