Database Reference
In-Depth Information
2. You will see a link in the results pane of the query pane. Click the link, and you
should see the results in Figure 7-2.
Figure 7-2. Using FOR XML RAW ELEMENTS
How It Works
RAW ELEMENTS mode produces very “element-centric” XML. It turns each row in the result set where each
column is converted into an attribute.
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: Renaming the row Element
For each row in the result set, the RAW mode generates an element called row . You can optionally specify
another name for this element by specifying an optional argument to the RAW mode, as shown in this
query. To achieve this, you need to add an alias after the FOR XML RAW clause, as shown in the following
query.
1. Replace the existing query in query window with the following query, and click
Execute:
 
Search WWH ::




Custom Search