XQuery [modify()]: 命名空间前缀 'dt' 尚未定义

XQuery [modify()]: The namespace prefix 'dt' has not been defined

我正在尝试更新 SQL 服务器中现有的 XML 列值。

declare @xml xml;
select @xml = 
'<items xmlns:dt="urn:schemas-microsoft-com:datatypes">
<item dt:dt="string">Item1<item>
</items>';
set @xml.modify('insert <item dt:dt="string">Item2</item> into (/items)[1]');

这会引发错误: XQuery [modify()]: 命名空间前缀'dt' 尚未定义

如何将命名空间引入修改?

declare @xml xml;
select @xml = 
'<items xmlns:dt="urn:schemas-microsoft-com:datatypes">
<item dt:dt="string">Item1</item>
</items>';
select @xml;

set @xml.modify('declare namespace dt="urn:schemas-microsoft-com:datatypes"; insert <item dt:dt="string">Item2</item> into (/items)[1]');

select @xml;