Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 2.65 KB

xml-transact-sql.md

File metadata and controls

70 lines (51 loc) · 2.65 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
xml (Transact-SQL)
xml (Transact-SQL)
MikeRayMSFT
mikeray
07/26/2017
sql
t-sql
reference
xml_TSQL
xml
xml data type [SQL Server], about xml data type
TSQL

xml (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

It's the data type that stores XML data. You can store xml instances in a column, or a variable of xml type.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

xml [ ( [ CONTENT | DOCUMENT ] xml_schema_collection ) ]

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

CONTENT
Restricts the xml instance to be a well-formed XML fragment. The XML data can contain multiple zero or more elements at the top level. Text nodes are also allowed at the top level.

This is the default behavior.

DOCUMENT
Restricts the xml instance to be a well-formed XML document. The XML data must have one and only one root element. Text nodes aren't allowed at the top level.

xml_schema_collection
Is the name of an XML schema collection. To create a typed xml column or variable, you can optionally specify the XML schema collection name. For more information about typed and untyped XML, see Compare Typed XML to Untyped XML.

Remarks

The stored representation of xml data type instances can't exceed 2 gigabytes (GB) in size.

The CONTENT and DOCUMENT facets apply only to typed XML. For more information, see Compare Typed XML to Untyped XML.

Examples

USE AdventureWorks;  
GO  
DECLARE @DemographicData XML (Person.IndividualSurveySchemaCollection);  
SET @DemographicData = (SELECT TOP 1 Demographics FROM Person.Person);  
SELECT @DemographicData;  
GO  

See Also