eZeeNow.com

it's your's

How to read xml data in sql server using select clause?

We can read the xml data using select clause.

DECLARE @xml XML = '<colors> 
<color><value>black</value><code>#fff</code></color>
<color><value>white</value><code>#000</code></color>
<color><value>gray</value><code>#coco</code></color>
</colors>'

SELECT doc.col.value('value[1]', 'nvarchar(4)')
,doc.col.value('code[1]', 'nvarchar(4)')
FROM @xml.nodes('colors/color') doc(col)

Comments (1) -

  • James

    7/20/2018 10:18:39 PM | Reply

    I really would like to attempt look at your blog one day before! they just make people go and i kind of want to have that power, once again, amazing stuff! It is very useful information.Thanks for sharing here. I am glad to see this blog .I just appreciate you for that kind of effort. Thanks and keep posting some. Amazing article. I am so impressed. I think you have a great knowledge especially while dealings with such subjects. Feel free to surf  https://writeversity.com .Education contain different task like essay, assignment, research paper writing and many of the students cannot complete their task successfully within the time.  

Loading