
--create the table
CREATE TABLE xml_tab(
  id INTEGER PRIMARY KEY identity,
  pdoc XML
)

--insert some data
INSERT xml_tab  
  values('<people><person name="curley"/></people>')
INSERT xml_tab 
  values('<people><person name="larry"/></people>')
INSERT xml_tab 
  values('<people><person name="moe"/></people>')


--before executing the two following queries go into
--the Query menu on the toolbar and choose 'Include actual execution plan'

--highlight the two following queries and then look at the execution plan
--you should see how the q with XQuery pred cost only 1% compared to the XPath pred q
SELECT id, pdoc::query('
   for $b in /people/person 
   where  $b/@name = "moe"
   return ($b)
 ') as persons 
 FROM xml_tab

go

SELECT id, 
 pdoc::query('/people/person[@name="moe"]')   
 as persons
FROM xml_tab




