--- title: "Server-side XML Formatting (SQLXML)" description: Learn about the server-side XML formatting of documents generated by SQLXML 4.0 queries executed against a Microsoft SQL Server database. ms.date: "03/14/2017" ms.prod: sql ms.prod_service: "database-engine, sql-database" ms.reviewer: "" ms.technology: xml ms.topic: "reference" helpviewer_keywords: - "FOR XML clause, formatting" - "server-side XML formatting" ms.assetid: ae9ea068-0857-4505-a3b2-f53d256b644c author: rothja ms.author: jroth ms.custom: "seo-lt-2019" monikerRange: "=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current" --- # Server-side XML Formatting (SQLXML 4.0) [!INCLUDE [SQL Server Azure SQL Database](../../../includes/applies-to-version/sql-asdb.md)] 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 [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)]. In [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)], 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 [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] that consists of the following [!INCLUDE[tsql](../../../includes/tsql-md.md)] 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: - RAW - AUTO - EXPLICIT For more information about the FOR XML clause, see [Constructing XML Using FOR XML](../../../relational-databases/xml/for-xml-sql-server.md). ## See Also [Architecture of Client-side and Server-side XML Formatting (SQLXML 4.0)](../../../relational-databases/sqlxml/formatting/architecture-of-client-side-and-server-side-xml-formatting-sqlxml-4-0.md) [Client-side XML Formatting (SQLXML 4.0)](../../../relational-databases/sqlxml/formatting/client-side-xml-formatting-sqlxml-4-0.md) [FOR XML (SQL Server)](../../../relational-databases/xml/for-xml-sql-server.md)