T-SQL - 将具有 XML 输出(包括命名空间)的查询保存到表或变量中
我想将下面查询的输出保存到变量或表中。 但是,它给出了一个错误,因为查询以“使用命名空间...”开头,
WITH XMLNAMESPACES (
'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2' as cac
, 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2' as cbc
)
select
'123456''cbc:ID'
, '20222903' 'cbc:IssueDate'
, 'Supplier name' 'cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name'
, ( select
'1' 'cac:Line'
, '3' 'cac:Quantity'
, '120.80' 'cac:LineTotal'
, '8594' 'cac:ItemCode'
for xml path ('cac:InvoiceLine' ) , type
)
for xml path ('') , type , root ('Invoice') ;
我试图将其存储到一个类似的变量中:
declare @content xml = WITH XMLNAMESPACES ......... ;
我还试图将其插入表中。
I would like to save the output from the query below into a variable or a table.
However it gives an error because the query starts with "With namespace ..."
WITH XMLNAMESPACES (
'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2' as cac
, 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2' as cbc
)
select
'123456''cbc:ID'
, '20222903' 'cbc:IssueDate'
, 'Supplier name' 'cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name'
, ( select
'1' 'cac:Line'
, '3' 'cac:Quantity'
, '120.80' 'cac:LineTotal'
, '8594' 'cac:ItemCode'
for xml path ('cac:InvoiceLine' ) , type
)
for xml path ('') , type , root ('Invoice') ;
I tried to store into an variable like:
declare @content xml = WITH XMLNAMESPACES ......... ;
And I also tried to insert into a table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该分配一个表达式,在选择周围使用括号
You should assign an expression, use brackets around the select