XML data type in SQL Server

The XML data type is used to store XML documents and fragments in a SQL Server database. You can create columns and variables of the XML type and store XML instances in them.

XML Data Type Methods

There are various methods that are as follows:

1.   Query()

2.   Value()

3.   
Exist()

4.   
Modify()

5.   Nodes()


Limitations of XML Data Type

1.    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.

4.  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.
Ebook Download
View all
Learn
View all