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

怎样容易修改这个
有个字段是CHAR类型,
数值是'xxxxxxxxd1006' 我想把末尾的为d1006 修改为 d106 不用游标,请问怎样做?

------解决方案--------------------
SQL code


select stuff('xxxxxxxxd1006',11,2,'0') as new
/*
new
xxxxxxxxd106
*/

------解决方案--------------------
SQL code

update tb
set col = reverse('d106'+right(reverse(col),len(col)-5))
where left(reverse(col),5) = 'd1006'

------解决方案--------------------
SQL code
update tb
set col =stuff('xxxxxxxxd1006',11,2,'0')
where col  like  '%d1006'

------解决方案--------------------
探讨
SQL code


update tb
set col = reverse('d106'+right(reverse(col),len(col)-5))
where left(reverse(col),5) = 'd1006'