T-SQL Question : Query to XML

Posted by Juvil John Soriano on Stack Overflow See other posts from Stack Overflow or by Juvil John Soriano
Published on 2010-03-09T10:59:34Z Indexed on 2010/03/09 11:06 UTC
Read the original article Hit count: 161

Filed under:
|

anyone can show me how to generate from this data

------------------------DATA--------------------------

Key ParentKey
5 NULL
25 5
33 25
26 5
27 5
34 27
28 5
29 5

to this XML result?

---------------------RESULTS--------------------------

    <record key="5" parentkey = "">
     <record key="25" parentkey = "5">
      <record key="33" parentkey = "25"></record>
      </record>
     </record>
     <record key="25" parentkey = "5">
     <record key="26" parentkey = "5">
     <record key="27" parentkey = "5">
      <record key="34" parentkey = "27"></record>
      </record>
     </record>
     <record key="28" parentkey = "5">
     <record key="29" parentkey = "5">
    </record>

© Stack Overflow or respective owner

Related posts about t-sql

Related posts about sql