0

I am trying to select certain values that are posted back to our sql server from an xml into one field as a string..

Example:

<?XMLVERSION><result><id>0</id><response>success</response><did>B2A5DY53</did><price>0.00</price></result>

How would I select just the value between "price" ' ' "/price"?

1 Answer 1

1

You can use the built-in ExtractValue() function for this:

SELECT ExtractValue('<result>
<id>0</id>
<response>success</response>
<did>B2A5DY53</did>
<price>0.00</price>
</result>', '/result/price')
Sign up to request clarification or add additional context in comments.

2 Comments

Is it not possible to use the field name like: SELECT ExtractValue(xml_field, '/result/price')?
Yes, you can use a column name as the first argument of ExtractValue(). I only used an XML string since you used one in your example.

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.