Databases Reference
In-Depth Information
1. Replace the existing query in the query window with the following query and click
Execute:
SELECT ProductModelID, Name
FROM Production.ProductModel
WHERE ProductModelID between 98 and 101
FOR XML RAW,ELEMENTS
2. You will see a link in the results pane of the query window. Click the link, and you
should see the results shown in Figure 7-2.
Figure 7-2. Using FOR XML RAW ELEMENTS
How It Works
FOR XML RAW ELEMENTS mode ode produces very “element-centric” XML. It turns each row
in the result set where each column is converted into an attribute.
FOR XML RAW ELEMENTS mode also doesn't produce an XML document, since it has as
many root elements ( raw ) as there are rows in the result set, and an XML document can
have only one root element.
Try It Out: Renaming the row Element
For each row in the result set, the FOR XML RAW mode generates a row element. You can
optionally specify another name for this element by including an optional argument in
Search WWH ::




Custom Search