根据主题SQL Server XML modify with no result while 在插入新节点之前我收到错误
XQuery [modify()]: Only non-document nodes can be inserted. Found "xs:string ?".
新节点的主体:
<formant id="'+lower(newid())+'" name="_name" width="155" height="20" x="125" y="761"
tabindex="0" source-name="_sn" readonly="false" required="false"
font="_fnt"><value></value></formant>
任何想法如何解决它?
DECLARE @newNodeData varchar(max) = <formant id="'+lower(newid())+'" name="_name" width="155" height="20" x="125" y="761"
tabindex="0" source-name="_sn" readonly="false" required="false"
font="_fnt"><value></value></formant>
...@newNodeData 变量上的一些文本修改
然后
declare @xml xml;
select @xml = t.xmlData //t.xmlData is ntext type
from table t
where id=123
set @xml.modify('declare namespace xsd="http://www.cebip.pl/xml/schematy/formularze/v1.0/definicja-formularza.xsd"; insert sql:variable("@newNodeData") as first into (/xsd:form-definition/xsd:page)[1]')
update table
set xmlData = @newNodeData
where id=123