结果集为:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
3.XML.Modify(replace)语句介绍
--替换属性
set @XMLVar.modify('replace value of(/catalog[1]/book[1]/@category))
with ("替换属性")'
--替换内容
set @XMLVar.modify('replace value of(/catalog[1]/book[1]/author[1]/text()[1]))
with("替换内容")'
--条件替换
set @XMLVar.modify('replace value of (/catalog[1]/book[2]/@category))
if(count(/catalog[1]/book)>4) then
"条件替换1"
else
"条件替换2")'
SELECT @XMLVar.query('/catalog[1]');
结果集为:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
作者“cnming”