ms sql query multiple table colums as identical tag (sequel)ms sql query multiple table colums as identical...

Did Shadowfax go to Valinor?

Stopping power of mountain vs road bike

How can I fix/modify my tub/shower combo so the water comes out of the showerhead?

Assassin's bullet with mercury

What is a clear way to write a bar that has an extra beat?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Why does Kotter return in Welcome Back Kotter?

What mechanic is there to disable a threat instead of killing it?

How can I make my BBEG immortal short of making them a Lich or Vampire?

How much of data wrangling is a data scientist's job?

Today is the Center

A reference to a well-known characterization of scattered compact spaces

Intersection of two sorted vectors in C++

Infinite Abelian subgroup of infinite non Abelian group example

Does a druid starting with a bow start with no arrows?

How could indestructible materials be used in power generation?

Is it inappropriate for a student to attend their mentor's dissertation defense?

1960's book about a plague that kills all white people

Doing something right before you need it - expression for this?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

I'm flying to France today and my passport expires in less than 2 months

Were any external disk drives stacked vertically?

How to model explosives?



ms sql query multiple table colums as identical tag (sequel)


ms sql query multiple table colums as identical tagSelect XML values when attribute involvedHow to include concatenated values in a dynamic pivot column value?Parsing Typed XML with a default namespace and inconsistent root nodeHowto query xmlFull text search in XML documentsSQL Row concatenation with XML PATH and STUFF giving aggregate sql errorGet attribute value of XMLDistinct XML values mysqlINSERT/SELECT xml column from one table to anotherms sql query multiple table colums as identical tag






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







-1















Extending this original question



I am using SQL Server Express 2017



Pretending this is my source table:



+-------------+---------------------------+
| ID | Name | Age | HairColor | HasCar |
+-------------+---------------------------+
| 1 | Bert | 25 | blonde | 1 |
| 2 | Agnes | 61 | white | 0 |
| 3 | Diane | 43 | brunette | 1 |
+-------------+---------------------------+


How can get a result looking like this?



<MyRootElement>
<MyGroupingTag Group="a">
<MyTag Value="1" />
<MyTag Value="Bert" />
<MyTag Value="25" />
<MyTag Value="blonde" />
<MyTag Value="1" />
</MyGroupingTag>
<MyGroupingTag Group="b">
<MyTag Value="2" />
<MyTag Value="Agnes" />
<MyTag Value="61" />
<MyTag Value="white" />
<MyTag Value="0" />
</MyGroupingTag>
<MyGroupingTag Group="c">
<MyTag Value="3" />
<MyTag Value="Diane" />
<MyTag Value="43" />
<MyTag Value="brunette" />
<MyTag Value="1" />
</MyGroupingTag>
</MyRootElement>


Because of the Group attribute in MyGroupingTag I can't use something like



SELECT... FOR XML PATH('MyTag'), ROOT('MyGroupingTag')









share







New contributor




GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    -1















    Extending this original question



    I am using SQL Server Express 2017



    Pretending this is my source table:



    +-------------+---------------------------+
    | ID | Name | Age | HairColor | HasCar |
    +-------------+---------------------------+
    | 1 | Bert | 25 | blonde | 1 |
    | 2 | Agnes | 61 | white | 0 |
    | 3 | Diane | 43 | brunette | 1 |
    +-------------+---------------------------+


    How can get a result looking like this?



    <MyRootElement>
    <MyGroupingTag Group="a">
    <MyTag Value="1" />
    <MyTag Value="Bert" />
    <MyTag Value="25" />
    <MyTag Value="blonde" />
    <MyTag Value="1" />
    </MyGroupingTag>
    <MyGroupingTag Group="b">
    <MyTag Value="2" />
    <MyTag Value="Agnes" />
    <MyTag Value="61" />
    <MyTag Value="white" />
    <MyTag Value="0" />
    </MyGroupingTag>
    <MyGroupingTag Group="c">
    <MyTag Value="3" />
    <MyTag Value="Diane" />
    <MyTag Value="43" />
    <MyTag Value="brunette" />
    <MyTag Value="1" />
    </MyGroupingTag>
    </MyRootElement>


    Because of the Group attribute in MyGroupingTag I can't use something like



    SELECT... FOR XML PATH('MyTag'), ROOT('MyGroupingTag')









    share







    New contributor




    GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      -1












      -1








      -1








      Extending this original question



      I am using SQL Server Express 2017



      Pretending this is my source table:



      +-------------+---------------------------+
      | ID | Name | Age | HairColor | HasCar |
      +-------------+---------------------------+
      | 1 | Bert | 25 | blonde | 1 |
      | 2 | Agnes | 61 | white | 0 |
      | 3 | Diane | 43 | brunette | 1 |
      +-------------+---------------------------+


      How can get a result looking like this?



      <MyRootElement>
      <MyGroupingTag Group="a">
      <MyTag Value="1" />
      <MyTag Value="Bert" />
      <MyTag Value="25" />
      <MyTag Value="blonde" />
      <MyTag Value="1" />
      </MyGroupingTag>
      <MyGroupingTag Group="b">
      <MyTag Value="2" />
      <MyTag Value="Agnes" />
      <MyTag Value="61" />
      <MyTag Value="white" />
      <MyTag Value="0" />
      </MyGroupingTag>
      <MyGroupingTag Group="c">
      <MyTag Value="3" />
      <MyTag Value="Diane" />
      <MyTag Value="43" />
      <MyTag Value="brunette" />
      <MyTag Value="1" />
      </MyGroupingTag>
      </MyRootElement>


      Because of the Group attribute in MyGroupingTag I can't use something like



      SELECT... FOR XML PATH('MyTag'), ROOT('MyGroupingTag')









      share







      New contributor




      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Extending this original question



      I am using SQL Server Express 2017



      Pretending this is my source table:



      +-------------+---------------------------+
      | ID | Name | Age | HairColor | HasCar |
      +-------------+---------------------------+
      | 1 | Bert | 25 | blonde | 1 |
      | 2 | Agnes | 61 | white | 0 |
      | 3 | Diane | 43 | brunette | 1 |
      +-------------+---------------------------+


      How can get a result looking like this?



      <MyRootElement>
      <MyGroupingTag Group="a">
      <MyTag Value="1" />
      <MyTag Value="Bert" />
      <MyTag Value="25" />
      <MyTag Value="blonde" />
      <MyTag Value="1" />
      </MyGroupingTag>
      <MyGroupingTag Group="b">
      <MyTag Value="2" />
      <MyTag Value="Agnes" />
      <MyTag Value="61" />
      <MyTag Value="white" />
      <MyTag Value="0" />
      </MyGroupingTag>
      <MyGroupingTag Group="c">
      <MyTag Value="3" />
      <MyTag Value="Diane" />
      <MyTag Value="43" />
      <MyTag Value="brunette" />
      <MyTag Value="1" />
      </MyGroupingTag>
      </MyRootElement>


      Because of the Group attribute in MyGroupingTag I can't use something like



      SELECT... FOR XML PATH('MyTag'), ROOT('MyGroupingTag')







      sql-server xml





      share







      New contributor




      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 8 mins ago









      GeorgeDukeGeorgeDuke

      12




      12




      New contributor




      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      GeorgeDuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          GeorgeDuke is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234011%2fms-sql-query-multiple-table-colums-as-identical-tag-sequel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          GeorgeDuke is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          GeorgeDuke is a new contributor. Be nice, and check out our Code of Conduct.













          GeorgeDuke is a new contributor. Be nice, and check out our Code of Conduct.












          GeorgeDuke is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234011%2fms-sql-query-multiple-table-colums-as-identical-tag-sequel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...