Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 2.9 KB

File metadata and controls

77 lines (61 loc) · 2.9 KB
title xml (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 07/26/2017
ms.prod sql
ms.prod_service database-engine, sql-database
ms.service
ms.component t-sql|xml
ms.reviewer
ms.suite sql
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
xml_TSQL
xml
dev_langs
TSQL
helpviewer_keywords
xml data type [SQL Server], about xml data type
ms.assetid 9198f671-8e61-4ca4-9c3a-859f84020e62
caps.latest.revision 35
author douglaslMS
ms.author douglasl
manager craigg
ms.workload On Demand

xml (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-asdb-xxxx-xxx-md]

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

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
xml ( [ CONTENT | DOCUMENT ] xml_schema_collection )  

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 are not 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 cannot 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

Data Type Conversion (Database Engine)
Data Types (Transact-SQL)
xml Data Type Methods
XQuery Language Reference (SQL Server)