Chapter 31. Using XML, XPath, and XQuery

In This Chapter

  • Using the XML data type

  • Creative FLWOR queries

  • Merging SQL and XQuery

  • Decomposing XML

The Internet is moving from being a vehicle primarily for e-mail and data presentation (web pages) into a phase that also includes high-performance data connectivity using service-oriented architecture and XML. With XML becoming ubiquitous, data architects must decide what role XML will play within their database designs. Fortunately, SQL Server 2005 provides the technical options to accommodate nearly any architectural choice.

During the "Get Ready for SQL Server 2005 Road Show," in the fall of 2005, when I presented the new XML capabilities, the most common question was, "Why do I want XML in my database?" No one in the SQL Server community is suggesting that the XML will replace relational data, but there may be situations when it makes sense to store some XML data, such as when XML documents are received, handled, and then discarded. When the data is semi-structured, meaning that the format of the data changes frequently over time or source, then a fluid XML document may be more efficient than fixed relational data.

Note

For an introduction to XML, XML Schema, and XST, download the XMLPrimer.pdf file from the book's web site, www.SQLServerBible.com. Sample code from this chapter, plus additional XML code samples, are available in the file ch31.sql.

Note

SQL Server 2000 had first-generation XML capabilities to publish to the Web and work with XML ...

Get SQL Server™ 2005 Bible 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.