Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 2.53 KB

File metadata and controls

53 lines (39 loc) · 2.53 KB
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.
author MikeRayMSFT
ms.author mikeray
ms.date 03/14/2017
ms.service sql
ms.subservice xml
ms.topic reference
helpviewer_keywords
FOR XML clause, formatting
server-side XML formatting
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 Azure SQL Managed Instance] 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 [!INCLUDEssNoVersion].

In [!INCLUDEssNoVersion], 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 [!INCLUDEssNoVersion] that consists of the following [!INCLUDEtsql] 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.

See Also

Architecture of Client-side and Server-side XML Formatting (SQLXML 4.0)
Client-side XML Formatting (SQLXML 4.0)
FOR XML (SQL Server)