I want insert into two element in if statements,for example:
x.modify('insert if (/a)>1') then element **a{1} b{1}**
…………………………
a{1} b{1} is not allowed together. please tell me how to deal with it. thx
a{1} b{1} is not allowed together. please tell me how to deal with it
Have a look at Sequence Expressions (XQuery).
declare @X xml = '<a>2</a>';
set @X.modify('insert (element a{1}, element b{1}) as last into (/a[text() > 1]/..)[1]');
select @X;
Result:
<a>2</a>
<a>1</a>
<b>1</b>