0

Well i am having an interesting thing to discuss with you all people. i am having table in database where one column is having xml data with certain fields. I want to fetch those field using select query. So tell me if you can suggest something to me.

Thanks a lot in advance.

2
Contributors
4
Replies
14
Views
4 Years
Discussion Span
Last Post by ManthanB
0

Assume you have this XML in column XmlData:

<item><title>1<title><description>A</description></item>
<item><title>2<title><description>B</description></item>

You can select nodes using a CROSS APPLY. Something like:

SELECT 
    node.value('(./title)[1]', 'VARCHAR(100)') AS title,
    node.value('(./description)[1]', 'VARCHAR(1000)') as description
FROM table 
CROSS APPLY XmlData.nodes('/item') t(node)
0

Thanx a lot for the prompt reply... i forgot to mentioned an important thing that xml data is been saved into text data. I tried the query that you have mentioned above and it did not worked for me. Plz suggest something to help me out...

0

Well I solved the said issue with your useful help. I would like to appreciate that you have put in. Thanks a lot....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.