The xml data type lets you store XML documents and fragments in a SQL Server database. An XML fragment is an XML instance that is missing a single top-level element. You can create columns and variables of the xml type and store XML instances in them.
You can optionally associate an XML schema collection with a column, a parameter, or a variable of the xml data type. The schemas in the collection are used to validate and type the XML instances. In this case, the XML is said to be typed.
The xml data type and associated methods help integrate XML into the relational framework of SQL Server. For more information, see xml Data Type Methods.
Limitations of the xml Data Type
Note the following general limitations that apply to the xml data type:
-
The stored representation of xml data type instances cannot exceed 2 GB.
-
It cannot be used as a subtype of a sql_variant instance.
-
It does not support casting or converting to either text or ntext. Use varchar(max) or nvarchar(max) instead.
-
It cannot be compared or sorted. This means an xml data type cannot be used in a GROUP BY statement.
-
It cannot be used as a parameter to any scalar, built-in functions other than ISNULL, COALESCE, and DATALENGTH.
-
It cannot be used as a key column in an index. However, it can be included as data in a clustered index or explicitly added to a nonclustered index by using the INCLUDE keyword when the nonclustered index is created.
See the topics in this section for more specific limitations of the xml data type.
Reference
Using FOR XML and OPENXML to Publish and Process XML Data
Concepts
Sample XML Applications
Help and Information
Getting SQL Server 2008 Assistance