1
使用SQL Server 2008我想将下面的XML转换为下面的表结构。 XML由第三方提供,不能更改,除recordid以外,每个表都有一个未知元素列表。在不知道架构的情况下解析XML
DECLARE @xml XML = '
<NewDataSet>
<Table1>
<recordid>1</recordid>
<Q2_1>aaaa</Q2_1>
<Q2_2>bbbb</Q2_2>
</Table1>
<Table1>
<recordid>2</recordid>
<R2_1>eeee</R2_1>
<R2_2>ffff</R2_2>
</Table1>
<Table1>
<recordid>3</recordid>
<R2_1>iiii</R2_1>
<Q2_2>jjjj</Q2_2>
</Table1>
</NewDataSet>';
样品台
recordid ElementName Value
----------------------------------------------------------
1 Q2_1 aaaa
1 Q2_2 bbbb
2 R2_1 eeee
2 R2_2 ffff
3 R2_1 iiii
3 Q2_2 jjjj
的感谢!那很完美 :) – ma9mwah