This topic provides information about formatting XML documents on the server side from the rowsets that are generated by queries executed against a database in Microsoft SQL Server.
In SQL Server, you can store and retrieve XML documents to and from database tables. To retrieve an XML document, use the FOR XML query extension in a SELECT query.
For example, assume a client application executes a command against SQL Server that consists of the following Transact-SQL query:
SELECT FirstName, LastName FROM Person.Contact FOR XML AUTO
The server executes the query in two steps. First, the server executes this SELECT statement:
SELECT FirstName, LastName FROM Person.Contact
Then the server applies the FOR XML transformation to the generated rowset. The resulting XML is then sent to the client as a one-column rowset. In this documentation, this process is referred to as server-side XML formatting.
On the server side, you can specify the following modes with a FOR XML clause:
For more information about the FOR XML clause, see Constructing XML Using FOR XML.