Yukon PDC bits and XQuery ...

If you have Yukon PDC beta bits and you are utilizing XQuery for your next project, you got to try this out. Maybe this is old news but it's sure beneficial to me.

1. Create a new database with SQL Server Workbench.
2. Create a table that allows Xml Document

Create

TABLE XMLDocument (id int identity,
         xdoc xml not null, constraint pkdocs PRIMARY KEY(id))

3. Grab an Xml file, I am using samples from XML Query Use Cases and save it to a local file.
4. Insert Xml data into the newly created table

Insert Into XMLDocument
Select * From OPENROWSET(bulk 'c:\input.xml' single_nclob)
as n

5. Try out XQuery on your document

Select

xdoc::query('
<results>
{
for $b in /bib/book
  return
    <result>
      { $b/title }
      {
        for $a in $b/author
          return $a
      }
    </result>
}
</results>
') from XMLDocument

This posting is provided "AS IS" with no warranties, and confers no rights.