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 8242249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:06:11+00:00 2026-06-07T21:06:11+00:00

I have three XML columns in my SQL Table (single row table just used

  • 0

I have three XML columns in my SQL Table (single row table just used for storing XML) and the XML structure is something like this:

In Column 1 –

<Column1XML>
    ....
</Column1XML>

In Column 2 –

<Column2XML>
    ....
</Column2XML>

In Column 3 –

<Column3XML>
    ....
</Column3XML>

The final resultant XML that I am looking for is:

<SomeTagName>
    <Column1XML>
        ....
    </Column1XML>
    <Column2XML>
        ....
    </Column2XML>
    <Column3XML>
        ....
    </Column3XML>
</SomeTagName>

How can I obtain this required structure without doing string concatenation? I am sure there must be a way out with Typed XML.

Thanks in advance for looking up my question.

  • 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-07T21:06:13+00:00Added an answer on June 7, 2026 at 9:06 pm

    Here are two ways for you.

    Sample data

    declare @T table
    (
      Col1 xml,
      Col2 xml,
      Col3 xml
    )
    
    insert into @T values
    (
    '<Column1XML></Column1XML>',
    '<Column2XML></Column2XML>',
    '<Column3XML></Column3XML>'
    )
    

    Use the root name as column alias

    select Col1 as 'SomeTagName',
           Col2 as 'SomeTagName',
           Col3 as 'SomeTagName' 
    from @T
    for xml path('')
    

    Use * as column alias and specify a path().

    select Col1 as '*',
           Col2 as '*',
           Col3 as '*' 
    from @T
    for xml path('SomeTagName')
    

    Result:

    <SomeTagName>
      <Column1XML />
      <Column2XML />
      <Column3XML />
    </SomeTagName>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML structure like the following: <tables> <table name=tableName1> <row ID=34 col1=data
I have a TableLayout defined in my xml with three columns and four rows
i have a table like this one: id | name | score mapped to
I have a data table in SQL 2008 R2 which is used to store
I have a table in SQL Server in which one of the columns is
I have a table called People with a columns of datatype xml called properties
I have a table with a few relational columns and one XML column which
I have an SQL (Microsoft SQL 2008) table with XML data in one of
I have a datagrid with an XML object as dataprovider. There are 2 columns
I have some xml data contained in three files (Database.xml, Participants.xml, and ConditionTokens.xml). I

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.