• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

SQL Server - Parse XML Field

Have a table with XML datatype.

Are there any ways inherit in SQL to parse the fields out?

So do a select but pull specific fields from the XML data.
1 Solution
You can use XQuery in SQL Server. For example if you have an xml column called Column1 in a Table called Table1 and that column has rows which contain an XML with the format <rootnode><innerNode attributeName=attributeValue></innerNode></rootNode>, you can extract all attribute values with a query like so.

SELECT Column1.value('(/rootNode/innerNode/@attributeName)[1]', 'varchar') AS SomeColumnName FROM Table1.
EricLynnWrightAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now