XQuery and SQL Server



XQuery and SQL Server

The previous two chapters discussed how the XPathDocument2 and XmlAdapter classes can be used for retrieving and updating data as XML from SQL Server, via XML Views that use XQuery as the XML query language. In this chapter, we'll look in more detail at the XQuery language, the XQueryProcessor class, and how they can be used to perform queries over XML documents loaded into an XPathDocument2 and over SQL Server using XML views.

We'll see how XQuery can be used as a data aggregation language for retrieving data from numerous different data sources, such as different SQL Server databases or a combination of SQL Server and XML documents on disk files. We will then discuss and demonstrate the XsltProcessor class used for performing XSLT transformations. It shares a Common Query Architecture with the XQueryProcessor class. Finally, this chapter looks at the XML data type introduced into SQL Server "Yukon," which enables it to store XML as a native type.

So, the topics for this chapter are:

  • A very brief overview of the XQuery language

  • Using the XQueryProcessor class

  • Using the XsltProcessor class

  • The Common Query Architecture

  • Using SQL Server as an XML database

We'll start with a look at what is now the primary way to query XML documents, the XQuery language.