339
CHAPTER
14
Using XML Data
IN THIS CHAPTER
Understanding The XML Data Type
Using The XML Data Type Methods
Working With The FOR XML Clause
Understanding XQuery And FLOWR Operations
T
he ability to process XML in SQL Server began with SQL Server 2000. Since then, many wonder-
ful and signifi cant changes and enhancements have been added to SQL Server to make working
with and processing XML easier and more effi cient.
With SQL Server 2005, Microsoft added the XML data type and other great XML features, such as
support for XML data type methods and using XML as a variable and parameter. SQL Server 2008
and SQL Server 2008 R2 added even more support, such as support for the let clause of the FLWOR
operations.
Although there haven’t been any major enhancements to XML in Denali, working with XML is
and always will be crucial in nearly every environment. It should be obvious that Microsoft is
embracing XML all the way because you can see XML used in nearly every aspect. For example,
SQL Server Reporting Services report defi nitions are actually just XML documents. SQL Server
Integration Services packages are XML documents and support XML confi guration fi les. And there
is a lot more.
This chapter covers some of the major areas to work with XML, including the XML data type in both
column form and variable form. It also talks about the methods used to query XML, and follows
that up by discussing the FOR XML clause, which is used to turn tabular data into many different
formats of XML. The chapter fi nishes by discussing XQuery, a language designed to query XML, and
the related FLWOR operations, which provide query and transformation capabilities against XML
documents.
c14.indd 339c14.indd 339 7/30/2012 4:48:58 PM7/30/2012 4:48:58 PM
http://www.it-ebooks.info