我目前正在尝试使用以下代码将xml节点插入到SQL Server中的表字段中。我试图在插入中声明命名空间但我继续得到未声明的前缀。我究竟做错了什么?
代码:
Declare @Term XML = '<wma:Term>My First Term</wma:Term>'
Declare @x XML
Select @x = MetaData from [Products] where Id = 1
Set @x.modify ('declare namespace wma="http://www.google.com/wma"; insert sql:variable("@Term") as last into (/wma:WMA/wma:List)[1]
预期结果:
<wma:WMA xmlns:wma="http://www.google.com/wma">
<wma:List>
<wma:Term>My First Term</wma:Term>
</wma:List>
</wma:WMA>