sum
101000
101053
101012
101015
101062
101016
101017
101018
101025
101046
101045
101047
想把列SUM中全部修改为5位,去掉第二位'0'
101000
101053
101012
101015
101062
101016
101017
101018
101025
101046
101045
101047
想把列SUM中全部修改为5位,去掉第二位'0'
调试欢乐多
set [sum]=stuff([sum],2,1,'')
set [sum]=stuff(ltrim([sum]),2,1,0)
go
create table [tb]([sum] int)
insert [tb]
select 101000 union all
select 101053 union all
select 101012 union all
select 101015 union all
select 101062 union all
select 101016 union all
select 101017 union all
select 101018 union all
select 101025 union all
select 101046 union all
select 101045 union all
select 101047
update tb
set [sum]=stuff([sum],2,1,'')select * from tb/**
sum
-----------
11000
11053
11012
11015
11062
11016
11017
11018
11025
11046
11045
11047(12 行受影响)**/
insert into #a values(101053)
insert into #a values(101012)
insert into #a values(101015)
insert into #a values(101062)
insert into #a values(101016)
insert into #a values(101017)
insert into #a values(101018)
insert into #a values(101025)
insert into #a values(101046)
insert into #a values(101045)
insert into #a values(101047)
select cast ( cast(left([sum],1) as varchar(10))+cast(right([sum],4) as varchar(10)) as int)
from #a
if not object_id('tb') is null
drop table tb
Go
Create table tb([sum] int)
Insert tb
select 101000 union all
select 101053 union all
select 101012 union all
select 101015 union all
select 101062 union all
select 101016 union all
select 101017 union all
select 101018 union all
select 101025 union all
select 101046 union all
select 101045 union all
select 101047
Go
update tb
set [sum]=stuff([sum],2,1,'')
select * from tb
/*
sum
-----------
11000
11053
11012
11015
11062
11016
11017
11018
11025
11046
11045
11047
*/