1
使用Microsoft SQL Server Management Studio中,我已经插入一个元素到XML文件,现在希望因此它看起来就像插入一个属性:使用SQL插入XML属性到XML文件
<a><b c="2"/></a>
update #tmp set column.modify('insert <b/> into (/a)[1]')
现在我希望创建作为c
的b
属性如上所示:
我与创建b
。所以我尝试:
update #tmp set column.modify('insert attribute c{''2''} into (/a/@b)[1]')
但我得到的错误:
XQuery [#tmp.column.modify()]: The target of 'insert into' must be an element/document node, found 'attribute(b,xdt:untypedAtomic)
它的工作原理,谢谢。我认为c是一个属性,但?我有他们翻转或什么?我错过了什么?我认为'b'是元素,内部会是一个属性? –
'c'是一个属性,'b'是一个元素。 '入'位需要一个元素目标(显然,我们不能拥有属性的属性:-) – StuartLC