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

Star79Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

unknown_routineCommented:
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

  ?
0
Star79Author Commented:
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>
0
unknown_routineCommented:
Take a look here:
http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/

however it is usually not the duty of DB layer to manipulate XML data, but DB sends this info to Businees layer to do the processing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony PerkinsCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.