2

I want to select the records from the Orders table. It contains the OrderXML as XML type column.

if OrderXML has order with status given by user then it should select the record. I am trying following query but not working -

SELECT * 
FROM   ORDER 
WHERE  ORDERXML.EXISTS('/Order/header/status/text()="Processing"') = 1 
6
  • possible duplicate of How can I query a value in SQL Server XML column Commented Jul 24, 2014 at 7:12
  • i don't understand is the question not clear? why down voting and closing? Commented Jul 24, 2014 at 7:13
  • I didn't down vote your Q. I suggest you follow the link in my prev comment, I think you'll find the answer there. Commented Jul 24, 2014 at 7:15
  • The shared link is useful. Commented Jul 24, 2014 at 7:24
  • 1
    Then you agree that this post is a duplicate? Try to do some searching first next time before you post a Q :-) Commented Jul 24, 2014 at 7:24

1 Answer 1

3

You need to put the predicate within brackets and exist need to be lower case. XML is case sensitive and even the XML function names in SQL Server is case sensitive.

select O.*
from [Order] as O
where O.OrderXML.exist('/Order/header/status[text() = "Processing"]') = 1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.