Link to home
Start Free TrialLog in
Avatar of Jim Horn
Jim HornFlag for United States of America

asked on

XQuery in SQL 2012: .exist with multiple criteria

How do you code in XQuery (SQL 2012) to do an .exist with multiple criteria?

Given the below XML..
Declare @x xml = '
<row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="page" itemValue="Confirmation" itemType="string" />
<row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="visited" itemValue="false" itemType="bool" />'

Open in new window

These two criteria work fine when queried individually...
SELECT @x.exist('/row[@Node eq "root.local.navigation[7]"]')
SELECT @x.exist('/row[@itemValue eq "Confirmation"]')

Open in new window

But when I combine them below it returns errmsg 'XQuery [exist()]: The XQuery syntax 'union' is not supported.'
SELECT @x.exist('/row[@Node eq "root.local.navigation[7]"] | /row[@itemValue eq "Confirmation"]')

Open in new window

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial