diandian82的专栏

Welcome to my blog. Hope you can get what you want.

使用SQL操作XML简单示例

declare @xml xml
set @xml = '<root/>'
select @xml

declare @value varchar(10)
set @value = 'val1'
set @xml.modify('insert <item value="{sql:variable("@value")}" /> into (/root)[1]')
select @xml

set @value = 'val2'
set @xml.modify('replace value of (/root/item/@value)[1] with "val2"')
select @xml

set @value = 'val3'
set @xml.modify('replace value of (/root/item/@value)[1] with sql:variable("@value")')
select @xml

阅读更多
文章标签: xml sql insert
个人分类: SQL Server XML
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭