Home > database >  Questions about the data update SQLSERVER2012 empty XML node
Questions about the data update SQLSERVER2012 empty XML node

Time:01-08

 
DECLARE @ t table (I int, XML) x
T select insert @ 1, select '0' as t1, 'as t2 for XML path)
Select * from @ t
The update @ t set x.m odify (' the replace the value of (/row/t1 [1]/text ()) [1] with "new" ')
The update @ t set x.m odify (' the replace the value of (/row/t2 [1]/text ()) [1] with "new1" ')
Select * from @ t

Through the above statement, found that when the XML node data is empty, the replace of the modify the value of invalid, what's the solution?

CodePudding user response:

 
Update @ t set x.m odify (' delete/row/t2 [1])
The update @ t set x.m odify (' insert & lt; T2 & gt; New

Delete first, then insert can be solved, but directly replace the value of why not? Is essentially a BUG?
  • Related