Quiz: Comparisons in XQuery vs T-SQL
I have the following two
statements. What is the difference? What would you expect
the results to be? Are you surprised by what you get?
select 1
where convert(xml, '<foo>bar</foo>').value('/foo[1]', 'nvarchar(4)') = 'Bar'
go
select 1
where convert(xml, '<foo>bar</foo>').exist('/foo[.="Bar"]') = 1
go
Comments
- Anonymous
July 05, 2005
Well (assuming the syntax is correct and all that, I've never used the XML datatype before), XQuery is case-sensitive, so the second one won't select anything. However, the first one may or may not select anything, depending on whether you've got your database set to use a case-sensitive collation or not. - Anonymous
July 11, 2005
Last week I threw out this simple little quiz.&nbsp; Here is the answer.
The first query will return...