我有下面的xml。我想动态加载到temp表中。当我试图以静态方式加载它时。当我尝试用pivot动态加载它时,它只给出一行(max或min值不是全部)
xml1格式:
'<ArrayOpp>
<Opp>
<ID>1251</ID>
<Type>Testing</Type>
<OppoType>Other</OppoType>
<CategoryName>Testing1</CategoryName>
<SubCategoryName>Testing1</SubCategoryName>
<Effort>1200.00</Effort>
</Opp>
<Opp>
<ID>1251</ID>
<Type>Testing</Type>
<OppoType>Other</OppoType>
<CategoryName>Testing2</CategoryName>
<SubCategoryName>Testing2</SubCategoryName>
<Effort>1200.00</Effort>
</Opp>
</ArrayOpp>'
结果:
ID Type OppoType CategoryName SubCategoryName Effort
1 Testing Other Testing1 Testing1 1000
2 Testing Other Testing2 Testing2 2000
如果xml再增加一个节点:cost
xml:2 [在此处输入图像描述][1]
'<ArrayOpp>
<Opp>
<ID>1251</ID>
<Type>Testing</Type>
<OppoType>Other</OppoType>
<CategoryName>Testing1</CategoryName>
<SubCategoryName>Testing1</SubCategoryName>
<Effort>1200.00</Effort>
<Cost>12.00</Cost>
</Opp>
<Opp>
<ID>1251</ID>
<Type>Testing</Type>
<OppoType>Other</OppoType>
<CategoryName>Testing2</CategoryName>
<SubCategoryName>Testing2</SubCategoryName>
<Effort>1200.00</Effort>
<Cost>12.00</Cost>
</Opp>
</ArrayOpp>'
结果:
ID Type OppoType CategoryName SubCategoryName Effort Cost
1 Testing Other Testing1 Testing1 1000 12.00
2 Testing Other Testing2 Testing2 2000 12.00
你能告诉我怎么做吗????
2条答案
按热度按时间ekqde3dh1#
可能我弄错了,但我看不出有什么必要使用动态方法(dynamicsql?),这两种方法也不需要
PIVOT()
.这两种方法都适用,没有任何问题:
drnojrws2#
尝试以下操作将xml数据加载到临时表:
静载荷
对于动态负载,请尝试以下方法:
动载荷