簡體   English   中英

XQuery [modify()]: 命名空間前綴 'dt' 尚未定義

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

我正在嘗試更新 SQL Server 中現有的 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()]: The namespace prefix 'dt' has not been defined

如何將命名空間放入修改中?

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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM