SQL Server - Parse XML Field

Posted on 2012-08-21
Last Modified: 2012-08-21
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.
Question by:EricLynnWright
    LVL 4

    Accepted 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.
    LVL 3

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now