日期:2014-05-18  浏览次数:20563 次

如何修改数组元素中的数值
我要修改数据库表news字段news_class   里面的内容
news_class字段的数据是数组   形式   "1,2,3,8,9 "

目前我要把数组元素中的一些数值进行修改了比如:

把数据库中有元素的数值是   2   的字段修改为改20


求一批处理语句


------解决方案--------------------
create table test(news_class varchar(20))
insert test select '1,2,3,8,9 '

update test set news_class=stuff(news_class,charindex( ',2, ', ', '+news_class+ ', '),1, '20 ')
select * from test

drop table test