下面是我已经创建的查询的简化版本。查询工作正常,但我无法弄清楚如何在生成的 XML 顶部获取 XML 声明。我已经尝试了多种方法并在 Google 上进行了广泛搜索,但可惜我似乎无法找到如何做到这一点......或者即使它是可能的。
select
'Dimension' "@type",
(
select
(
select
'X102' "TransactionType",
convert(varchar, getdate(), 104) "Transfer/TransferDate",
convert(varchar, getdate(), 108) "Transfer/TransferTime"
for xml path (''), type
) "TransactionInformation"
for xml path (''), type
)
for xml path ('DimensionImport'), type
给我...
<DimensionImport type="Dimension">
<TransactionInformation>
<TransactionType>X102</TransactionType>
<Transfer>
<TransferDate>21.01.2010</TransferDate>
<TransferTime>15:46:36</TransferTime>
</Transfer>
</TransactionInformation>
</DimensionImport>
我要...
<?xml version="1.0" encoding="ISO-8859-1" ?>
<DimensionImport type="Dimension">
<TransactionInformation>
<TransactionType>X102</TransactionType>
<Transfer>
<TransferDate>21.01.2010</TransferDate>
<TransferTime>15:46:36</TransferTime>
</Transfer>
</TransactionInformation>
</DimensionImport>
提前感谢您提供的任何帮助。