SQL Server 2008 need just like crosstab query on XML column?

Posted by user1332896 on Stack Overflow See other posts from Stack Overflow or by user1332896
Published on 2012-04-14T06:14:25Z Indexed on 2012/04/14 11:29 UTC
Read the original article Hit count: 295

Filed under:
|
<abc id="abc1">
  <def id="def1">
    <ghi att='ghi1'>
      <mn id="0742d2ea" name="RF"  dt="0" df="3" ty="0" />
      <mn id="64d9a11b" name="CJ"  dt="0" df="3" ty="0" />
      <mn id="db72d154" name="FJ"  dt="2" df="4" ty="0" />
      <mn id="39af9fa1" name="BS"  dt="0" df="2" ty="0" />
    </ghi>
    <jkl  att='jkl1'>
       <mn id="0742d2ea" name="RF" dt="1" gl="19" />
       <mn id="64d9a11b" name="CJ" dt="0" gl="6" />
       <mn id="db72d154" name="FJ" dt="0" gl="0" />
       <mn id="39af9fa1" name="BS" dt="0" gl="12" />
       <mn id="ac4f566f" name="DJ" dt="0" gl="9" />
       <mn id="4bf3ba2f" name="RP" dt="0" gl="16" />
       <mn id="db1af021" name="SC" dt="1" gl="10" />
       <mn id="c4c93a2d" name="DN" dt="1" gl="15" />
    </jkl>
  </def>
</abc>

I need this output. Is this possible in SQL Server 2008?

id          name ghiDT  ghiDF   ghiTY   jklDT   jklGL
0742d2ea    RF  0   3   0   1   19
64d9a11b    CJ  0   3   0   0   6
db72d154    FJ  2   4   0   0   0
39af9fa1    BS  0   2   0   0   12
ac4f566f    DJ  0   0   0   0   9
4bf3ba2f    RP  0   0   0   0   16
db1af021    SC  0   0   0   1   10
c4c93a2d    DN  0   0   0   1   15

© Stack Overflow or respective owner

Related posts about sql-server-2008

Related posts about xquery