其实可以不用存储过程的select ID, PHSum=left(PHSum,4)+'8'+substring(PHSum,5,len(PHSum)-4), Time from tb
create proc up_upgrade as update 表 set PHSum=stuff(PHSum,5,0,'8') goexec up_upgrade
create proc prc as begin update t set PHSum=case when left(PHSum,4) in ('0573','0575','0579','0576') then left(PHSum,4)+'8'+right(PHSum,len(PHSum)-4) end end
update table set PHSum = '05738' + SUBSTRING(PHSum,5, 100) where PHSum like '0573%'
create proc aa @a varchar(100) as update 表 set PHSum=stuff(PHSum,5,1,'8') where charindex(PHSum,@a)>0
create proc aa @a varchar(100) as update 表 set PHSum=stuff(PHSum,5,0,'8') where charindex(PHSum,@a)>0
create proc sp as begin update u set PHSum=case when left(PHSum,4) in ('0573','0575','0579','0576') then left(PHSum,4)+'8'+right(PHSum,len(PHSum)-4) end end
wgzaaa 不一定是第五信的, 因为是区号可能会有 010 021这样的
update 表 set PHSum=stuff(PHSum,5,0,'8') where left(PHSum,4) in ('0573','0575','0579','0576')
create proc aa @a varchar(100) as if charindex(',010,',','+@a+',')>0 update 表 set PHSum=stuff(PHSum,4,0,'8') where left(PHSum,3)='010' else if charindex(',020,',','+@a+',')>0 update 表 set PHSum=stuff(PHSum,4,0,'8') where left(PHSum,3)='020' else update 表 set PHSum=stuff(PHSum,5,0,'8') where charindex(left(PHSum,4),@a)>0
from tb
as
update 表
set PHSum=stuff(PHSum,5,0,'8')
goexec up_upgrade
as
begin
update t set PHSum=case when left(PHSum,4) in ('0573','0575','0579','0576') then
left(PHSum,4)+'8'+right(PHSum,len(PHSum)-4) end
end
update 表 set PHSum=stuff(PHSum,5,1,'8') where charindex(PHSum,@a)>0
update 表 set PHSum=stuff(PHSum,5,0,'8') where charindex(PHSum,@a)>0
charindex参数位置反了.
谢谢,我越来越能和你想到一块去了
as
begin
update u set PHSum=case when left(PHSum,4) in ('0573','0575','0579','0576') then
left(PHSum,4)+'8'+right(PHSum,len(PHSum)-4) end
end
set PHSum=stuff(PHSum,5,0,'8')
where left(PHSum,4) in ('0573','0575','0579','0576')
if charindex(',010,',','+@a+',')>0
update 表 set PHSum=stuff(PHSum,4,0,'8') where left(PHSum,3)='010'
else if charindex(',020,',','+@a+',')>0
update 表 set PHSum=stuff(PHSum,4,0,'8') where left(PHSum,3)='020'
else
update 表 set PHSum=stuff(PHSum,5,0,'8') where charindex(left(PHSum,4),@a)>0