DECLARE @t table(i int,x xml)
insert @t select 1,(select '0' as t1,'' as t2 for xml path)
select * from @t
update @t set x.modify('replace value of (/row/t1[1]/text())[1] with "new"')
update @t set x.modify('replace value of (/row/t2[1]/text())[1] with "new1"')
select * from @t
通過以上陳述句發現,當XML節點資料為空時,modify的replace value of無效,有什么辦法解決?
uj5u.com熱心網友回復:
update @t set x.modify('delete /row/t2[1]')
update @t set x.modify('insert <t2>new</t2> after (/row/t1)[1]')
先洗掉再插入可以解決,但直接replace value of為什么不行呢?是SQLSERVER的BUG嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/245986.html
標籤:疑難問題
