Database Reference
In-Depth Information
Figure 7-4.
Using FOR XML AUTO
How It Works
Three columns, Contact.Title, Contact.FirstName, and Contact.LastName , reference the Person.Contact
table. Therefore, an Person.Contact element is added, and the three columns are added as attributes of
Person.Contact.
Observations About XML AUTO Formatting
Here are tips about
XML AUTO
:
•
XML AUTO
does not provide a root node, which is why the XML structure is not a
well-formed XML document.
•
Since
XML AUTO
supports attribute- and element-centric formatting, all the
columns must be formatted in the same way. Hence, it is not possible to have an
XML structure returned with both the XML attributes and XML elements.
XML AUTO
does not provide a renaming mechanism the way
XML RAW
does, whereas
XML AUTO
uses the table and column names and aliases if present.
•