Link to home
Start Free TrialLog in
Avatar of Star79
Star79Flag for United States of America

asked on

Reading an xml file from SQL

Hello,
I have a table monographs and the data has filecontent which is a xml.When I run the below query it returns me the row for that drug.Now how can I search for all the filecontent which has <warnbox> as one of the xml tags as the below filecontent for this drug has warnbox as one of its tag,so basically Iam looking for all the filecontent which has this tag.Please help.



SELECT *
  FROM Monographs
  WHERE CAST(filecontent  AS VARCHAR(MAX)) LIKE '%abacavir%'

Open in new window

Avatar of unknown_routine
unknown_routine
Flag of United States of America image

I think your question is not clear enought.

your query

SELECT *
  FROM Monographs
  WHERE CAST(filecontent  AS VARCHAR(MAX)) LIKE '%abacavir%'

Open in new window


Will return all filecontent with the abacavir in them?

What's wrong with


SELECT *
  FROM Monographs
  WHERE CAST(filecontent  AS VARCHAR(MAX)) LIKE '%warnbox%'

Open in new window

  ?
Avatar of Star79

ASKER

true it actually works.
Another extension to this question.The file has a set of tag like below:how can I extract anything thats between generic-name tag.
Thanks.
<title>
      <generic-name>Azathioprine</generic-name>
      <doseform>Tablets</doseform>
    </title>
ASKER CERTIFIED SOLUTION
Avatar of unknown_routine
unknown_routine
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
Avatar of Anthony Perkins
so basically Iam looking for all the filecontent which has this tag.
You use the Xml Data Type Methods to filter the data you need.

If you can post a sample of your Xml and what nodes to filter on I can post an example.