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

Microsoft SQL Server 2005Microsoft SQL Server 2008

Avatar of undefined
Last Comment
Anthony Perkins
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
Star79
Flag of United States of America image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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.
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo