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

The Archive Base Latest Questions

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

We are in the process of upgrading our sql server to 2K8 R2 and

  • 0

We are in the process of upgrading our sql server to 2K8 R2 and the output of a FOR XML AUTO query has changed.

The query outputs columns from three tables

The resultset returns three rows which each column is identical bar the last two columns from the third table. the results used to show as below

<element1 myval="Test">
    <element2 myotherval="atest">
         <element3 a="a"/>
         <element3 a="b"/>
         <element3 a="c" />
    </element2>
</element1>

it not shows

    <element1 myval="Test">
        <element2 myotherval="atest">
             <element3 a="a"/>
         </element2>
    </element1>
    <element1 myval="Test">
        <element2 myotherval="atest">
             <element3 a="B"/>
         </element2>
    </element1>
    <element1 myval="Test">
        <element2 myotherval="atest">
             <element3 a="C"/>
         </element2>
    </element1>

I have been trying to use For XML Path but it still returns 3 separate instances of element1 rather than grouping the data.

  • 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:23:19+00:00Added an answer on May 16, 2026 at 4:23 am

    If you want a subtree using FOR XML PATH, you’ll have to write subqueries for each subtree. So in your case you have a parent select statement for element1, and one of the columns is a subquery that gets whatever needs to be in element2 (which in turn can also be subqueries). If you use subqueries and you want XML returned from those, use

    FOR XML PATH(‘elementN’), TYPE

    or it’ll escape the XML code.

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

Sidebar

Related Questions

We're in the process of upgrading one of our SQL Server instances from 2000
We are in the process of upgrading our projects from C# 2.0 / VS2005
We have in the process of upgrading our application to full Unicode comptibility as
We are in the process of upgrading our VS2008 to the new SP1, but
A Windows process created from an exe file has access to the command string
We are currently in the process of upgrading our rails version and I have
I've been upgrading our solutions from VS 2005 to VS 2008; still targeting the
I'm in the process of upgrading our VS 2008 solution to run on VS
we are in the process of upgrading our crappy cms system and the new
We're in the process of upgrading from VS2008 to VS2010 since it's now released.

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.