微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sql操作xml类型的的数据

查询

select * from ceshitable where ceshi.value('(ceshi/name)[1]','nvarchar(200)') like '%ceshi9%';

 

修改

update ceshitable set ceshi.modify('replace value of (ceshi/name//text())[1] with "修改后的值"') where ceshi.value('(ceshi/id)[1]','int') = 1;

 

 

 

排序:

select top 10 * from ceshitable order by ceshi.value('(ceshi/id)[1]', 'int')

 

汇总:

select SUM(ceshi.value('(ceshi/id)[1]','int')) from ceshitable where ceshi.value('(ceshi/id)[1]','int') <=10

 

 

 

分组:

select COUNT(*),table1.tName from (

SELECT table2.Loc.value('TitleIntact[1]','varchar(250)') as tName  FROM   PE_ContentManage_Article

CROSS APPLY ExtendContent.nodes('/ExtendContent') as table2(Loc)) as table1

GROUP by table1.tName

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。