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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:47:49+00:00 2026-06-13T15:47:49+00:00

I am selecting 2 sets of columns from the same table, as follows. select

  • 0

I am selecting 2 sets of columns from the same table, as follows.

select (select a, b, c from T1 FOR XML RAW('CAT1')),
       (select d, e, f from T1 FOR XML RAW('CAT2'))
for XML PATH('Parent')

The result of the query is

<Parent>&lt;CAT1 a="Data1" b="Data2', c="Data3" &gt;&lt;CAT2 d="Data4" e="Data5" f="Data6"&gt;</Parent>

How to avoid? I would get enclosed in a proper parent xml?

Expected Result

<Parent>
   <CAT1 a="Data1" b="Data2', c="Data3">
   <CAT2 d="Data4" e="Data5" f="Data6">
</Parent>
  • 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-13T15:47:50+00:00Added an answer on June 13, 2026 at 3:47 pm

    Use TYPE to specify that the sub queries should return XML.

    select (select a, b, c from T1 FOR XML RAW('CAT1'), TYPE),
           (select d, e, f from T1 FOR XML RAW('CAT2'), TYPE)
    for XML PATH('Parent')
    

    TYPE Directive in FOR XML Queries

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

Sidebar

Related Questions

I'm selecting products from a database table. Currently the query is launched from Coldfusion,
Background I have a table which has six columns. The first three columns create
PROCEDURE add_values AS BEGIN INSERT INTO TableA SELECT id, name FROM TableC (This selection
When selecting a DATE and that date does not exist in my table it
Let's say I have a data.table and I want to select all the rows
I'm trying to analyze data sets that are obtained from CSV files. After the
Does anyone have a suggestion on how to extract columns from a data set
Stepping back from the following question : Selecting with Cases I need to generate
when selecting a column that can contains a NULL value I get an exception
For selecting birthdays between two months where FROMDATE and TODATE are some parameters in

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.