Chapter 7. XML Data

SQL Server 2005 provides extensive support for XML data storage and processing. You can store XML documents and fragments natively as columns and T-SQL variables of the new xml data type. xml data type columns can be indexed, typed according to an XML schema, and manipulated using XQuery and XML Data Manipulation Language (DML).

A relational model is particularly suited to data that is highly structured with a well-known, well-defined schema. XML data, on the other hand, is suitable to handling data with a flexible, evolving, or unknown structure. XML is also well suited to storing data that represents a containment hierarchy.

Some reasons to store data as XML include the following:

  • Using the administrative capabilities of SQL Server to manage your XML data

  • Efficiently sharing, querying, and making fine-grained modifications to your XML data

  • Ensuring that data is validated against an existing XML schema

In addition to natively storing XML data, SQL Server 2005 lets you map relational data to XML data using XQuery extension functions and map XML data to relational data using the FOR XML clause.

SQL Server 2005 includes SQLXML 4.0. This extends and enhances the client-side XML functionality introduced in SQLXML 3.0, which shipped as a web release after the release of SQL Server 2000.

xml Data Type

The new xml data type supports storing both XML documents and fragments in the database. An XML fragment is an XML instance that does not have a single top-level (root) element. ...

Get Programming SQL Server 2005 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.