SQL Server 2005 の XML フィールドに保存する Excel XML を作成しようとしています。
WITH XMLNAMESPACES (
'urn:schemas-microsoft-com:office:spreadsheet' as "s",
'urn:schemas-microsoft-com:office:office' as "o",
'urn:schemas-microsoft-com:office:excel' as "x"
)
select 'Order' as "@s:Name",
(
select
'String' as 's:Cell/s:Data/@s:Type',
[Order] as 's:Cell/s:Data',
null as 'tmp',
'String' as 's:Cell/s:Data/@s:Type',
[Material] as 's:Cell/s:Data',
null as 'tmp',
'String' as 's:Cell/s:Data/@s:Type',
[Ship-To] as 's:Cell/s:Data'
from
(
select
'Order' as [Order],
'Material' as [Material],
'Ship-To' as [Ship-To]
union all
select
[Order],
[Material],
[Ship-To]
from Orders
WHERE [Material] IN(1234,5678))
) as Temp
FOR XML PATH('s:Row'), type
) AS 's:Table'
FOR XML PATH('s:Worksheet'), root('s:Workbook')
ここに私の出力があります:
<s:Workbook xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet">
<s:Worksheet s:Name="Order">
<s:Table>
<s:Row xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet">
<s:Cell>
<s:Data s:Type="String">Order</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">Material</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">Ship-To</s:Data>
</s:Cell>
</s:Row>
<s:Row xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet">
<s:Cell>
<s:Data s:Type="String">200909</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">1234</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">US</s:Data>
</s:Cell>
</s:Row>
<s:Row xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet">
<s:Cell>
<s:Data s:Type="String">200909</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">5678</s:Data>
</s:Cell>
<s:Cell>
<s:Data s:Type="String">ASIA</s:Data>
</s:Cell>
</s:Row>
</s:Table>
</s:Worksheet>
</s:Workbook>
私が望むのは、<s:Row>
ノードの名前空間を排除することです。これを取り除きたい:xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet"
から<s:Row xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:s="urn:schemas-microsoft-com:office:spreadsheet">
これを行う方法を知っている人はいますか?