Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • 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.
0
EricLynnWright
Asked:
EricLynnWright
1 Solution
 
fritzfrancisCommented:
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.
0
 
EricLynnWrightAuthor Commented:
thx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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