Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:16:09+00:00 2026-06-11T22:16:09+00:00

In a table, I have multiple rows, each containing xml based on common schema.

  • 0

In a table, I have multiple rows, each containing xml based on common schema. An example of the XML might be:

<Items>
    <Item>Item 1</Item>
    <Item>Item 2</Item>
</Items>

If I have multiple rows in a table, all containing similar xml, is it possible to write a query that returns all values in the Item node for all rows, in a single resultset? We’re using SQL Server 2008 R2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:16:11+00:00Added an answer on June 11, 2026 at 10:16 pm

    If your xml is defined in an XML column ..

    DECLARE @Items AS TABLE 
    (
        ItemXml XML
    )
    
    -- test data with a couple rows of xml
    INSERT INTO @Items(ItemXml)
    VALUES ('<Items><Item>Item 1</Item><Item>Item 2</Item></Items>')
          ,('<Items><Item>Item 3</Item><Item>Item 4</Item></Items>')
    
    -- the query
    SELECT t.i.value('.','VARCHAR(8000)') AS Item
    FROM @Items CROSS APPLY ItemXml.nodes('/Items/Item') t(i)
    

    Will give you

    Item
    ------
    Item 1
    Item 2
    Item 3
    Item 4
    

    The key here is nodes() which

    is useful when you want to shred an xml data type instance into
    relational data. It allows you to identify nodes that will be mapped
    into a new row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generated table that contains multiple rows with each row containing a
I have a table with multiple rows in each row is a select list
Ok, I have a table which contains multiple rows. Each row contains some data
My MysQL database contains multiple MyISAM tables, with each table containing millions of rows.
I have multiple table rows that has a set of radio buttons on each
I have this strange scenario. I have a table having multiple rows (each generated
I have an object which I'm filling with objects containing 2 table rows each.
I have a table with multiple rows and columns and each cell contains a
I have a table contains multiple rows and each row has an image. <table>
I have a table with multiple rows. Each row is a form. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.