December 2001
Intermediate to advanced
800 pages
17h 55m
English
The ELEMENTS option of the FOR XML AUTO clause causes AUTO mode to return nested elements instead of attributes. Depending on your business needs or those of your clients, element-centric mapping may be preferable to the default attribute-centric mapping. Here's an example of a FOR XML query that returns elements instead of attributes:
SELECT CustomerID, CompanyName FROM Customers FOR XML AUTO, ELEMENTS
(Results abridged and formatted)
XML_F52E2B61-18A1-11d1-B105-00805F49916B --------------------------------------------------------------------------- <Customers> <CustomerID>ALFKI</CustomerID> <CompanyName>Alfreds Futterkiste</CompanyName> </Customers> <Customers> <CustomerID>ANATR</CustomerID> <CompanyName>Ana Trujillo Emparedados ...
Read now
Unlock full access