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

  • Home
  • SEARCH
  • 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 982971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:46:55+00:00 2026-05-16T04:46:55+00:00

I have this XML in a SQL Server table: <root> <meetings> <meeting> <id>111</id> <participants>

  • 0

I have this XML in a SQL Server table:

<root>
  <meetings>
    <meeting>
      <id>111</id>
      <participants>
        <participant><name>Smith</name></participant>
        <participant><name>Jones</name></participant>
        <participant><name>Brown</name></participant>
      </participants>
    </meeting>
    <meeting>
      <id>222</id>
      <participants>
        <participant><name>White</name></participant>
        <participant><name>Bloggs</name></participant>
        <participant><name>McDonald</name></participant>
      </participants>
    </meeting>
  </meetings>
</root>

And want a result set like this:

MeetingID    Name
111          Smith
111          Jones
111          Brown
222          White
222          Bloggs
222          McDonald

This is easy using select from openxml but I failed using XQuery. Can someone help me there, and maybe also give pros and cons for either method?

  • 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-05-16T04:46:56+00:00Added an answer on May 16, 2026 at 4:46 am

    Once you’ve fixed your invalid XML (the <name> elements need to be ended with a </name> end tag), you should be able to use this:

    SELECT 
        Meetings.List.value('(id)[1]', 'int') AS 'Meeting ID',
        Meeting.Participant.value('(name)[1]', 'varchar(50)') AS 'Name'
    FROM
        @input.nodes('/root/meetings/meeting') AS Meetings(List)
    CROSS APPLY
        Meetings.List.nodes('participants/participant') AS Meeting(Participant)
    

    Basically, the first call to .nodes() gives you a pseudo-table of all <meeting> nodes, from which I extract the meeting ID.

    The second .nodes() call on that <meeting> tag digs deeper into the <participants>/<participant> list of subnodes and extracts the name from those nodes.

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

Sidebar

Related Questions

I have this XML in a column in my table: <keywords> <keyword name=First Name
I have a XML structure in a XML column on a SQL Server table
I have a SQL Server 2008 table with 50k rows, each with an XML
I have a table in SQL Server 2000 with a text field containing XML
I have a table called XML (in SQL Server 2008) and it has a
I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer
I have a table with the column's datatype as xml in SQL Server 2005.
Say I have this given XML file: <root> <node>x</node> <node>y</node> <node>a</node> </root> And I
I have created a sample query in sql server to parse data from xml
Using SQL Server 2008. I have a table variable with a single column and

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.