Database Reference
In-Depth Information
Figure 11-55
Continued
(c) FOr XML raW results in XML Document
Using another option, FOR XML EXPLICIT, you can cause SQL Server to place some
columns into elements and others into attributes. For example, you might decide to place all
column values except surrogate key values into elements and all surrogate key values into at-
tributes. The justification for this design is that surrogate key values have no meaning to the
users, so they are more like metadata than data. The means by which this is done is beyond
the scope of this discussion. See FOR XML EXPLICIT in the SQL Server 2012 documentation
on the FOR XML clause at http://msdn.microsoft.com/en-us/library/ms178107.aspx .
Figure 11-56
FOr XML aUtO, ELEMENtS
Examples
The SQL FOR XML
AUTO, ELEMENTS
query
The SQL FOR XML
AUTO, ELEMENTS
query results—click
this cell to display the
results in a separate
window
(a) FOr XML aUtO, ELEMENtS Query
Search WWH ::




Custom Search