new to xQuery -- problem



Hello All,
I am new to XQuery and also to SQL 2005. I am going through some
tutorials on how to select xml nodes out of the database and i have run
into a problem i can't figure out. So here is the Xml document that has
been stored in the database

'<Person>
<Detail>
<Name></Name>
<Gender></Gender>
<Age></Age>
<test test="test">test</test>
</Detail>
</Person>'

and in this example all i want to do is select all of the xmldocuments
by a specific order according to name, but when i put my order by
clause into the xquery statement i get an error

Msg 2389, Level 16, State 1, Line 3
XQuery [XmlTest.XmlData.query()]: 'order by' requires a singleton (or
empty sequence), found operand of type 'xdt:untypedAtomic *'

I have no idea what this error even means can anyone help.. what am i
doing wrong and what does this error message mean ... what's a
singleton? (Please excuse if this is a stupid question!!)

SELECT XmlData.query('
for $A in /Person/Detail
order by $A/Person/Detail.name
return
$A
') as Result
FROM XmlTest

.



Relevant Pages