2
我试图插入@newLinks
到@links
但我不知道如何申报下列SQL前缀“XSI”时申报命名空间:如何使用SQL变量插入多个XML节点
declare @links xml
set @links = N'<Links/>';
declare @newLinks xml
set @newLinks = N'
<Link xsi:type="CustomLink">
<Name>Foo</Name>
</Link>
<Link xsi:type="CustomLink">
<Name>Bar</Name>
</Link>';
set @links.modify('
insert sql:variable("@newLinks")
into (/Links)[1]');
select @links;
执行上面的SQL结果在下面的错误:
XML parsing: line 2, character 28, undeclared prefix
我尝试没有运气以下:
set @links.modify('
declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance";
insert sql:variable("@newLinks")
into (/Links)[1]');