在前一篇http://www.cnblogs.com/insus/archive/2012/02/25/2367857.html xml.modify()可以看到所在演示均是为变量的xml数据类型进行操作。Insus.NET想在此篇使用http://www.cnblogs.com/insus/archive/2012/02/25/2367701.html 篇中创建的表[dbo].[tbDevLanguage]中的数据进行操作。也就是说以表的xml的数据类型进行演示。在演示之前,Insus.NET修改了此表,添加了一个主键字段,方便过滤记录时行更新。
插入元素insert():
UPDATE
[
dbo
].
[
tbDevLanguage
]
SET [ languages ].modify( ' insert
<language name="PHP" />
into (/Languages)[1] '
) WHERE [ ID ] = 1
SET [ languages ].modify( ' insert
<language name="PHP" />
into (/Languages)[1] '
) WHERE [ ID ] = 1
删除元素delete():
UPDATE
[
dbo
].
[
tbDevLanguage
]
SET [ languages ].modify( ' delete
/Languages/language[4] '
) WHERE [ ID ] = 1
SET [ languages ].modify( ' delete
/Languages/language[4] '
) WHERE [ ID ] = 1
修改元素replace():
UPDATE
[
dbo
].
[
tbDevLanguage
]
SET [ languages ].modify( ' replace value of
/Languages[1]/language[1]/@name
with "J#" '
) WHERE [ ID ] = 1
SET [ languages ].modify( ' replace value of
/Languages[1]/language[1]/@name
with "J#" '
) WHERE [ ID ] = 1
演示: