急求一条update语句
表BB里有个字段AAA
AAA
12100
12101
13105
22104
22105
31102
31105
怎么更新成如下:
AAA
22100
22101
23105
32104
32105
41102
41105
帮忙!!
------解决方案--------------------create table tb(aaa varchar(10))
insert into tb values( '12100 ')
insert into tb values( '12101 ')
insert into tb values( '13105 ')
insert into tb values( '22104 ')
insert into tb values( '22105 ')
insert into tb values( '31102 ')
insert into tb values( '31105 ')
update tb
set aaa = cast(cast(left(aaa,1) as int) + 1 as varchar) + substring(aaa,2,len(aaa)-1)
select * from tb
drop table tb
/*
aaa
----------
22100
22101
23105
32104
32105
41102
41105
(所影响的行数为 7 行)
*/