update 表
set PHSum=stuff(PHSum,5,0,'8')

解决方案 »

  1.   

    其实可以不用存储过程的select ID, PHSum=left(PHSum,4)+'8'+substring(PHSum,5,len(PHSum)-4), Time
    from tb
      

  2.   

    create proc up_upgrade
    as
    update 表
    set PHSum=stuff(PHSum,5,0,'8')
    goexec up_upgrade
      

  3.   

    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
      

  4.   

    update table set  PHSum = '05738' + SUBSTRING(PHSum,5, 100)  where PHSum like '0573%'
      

  5.   

    create proc aa @a varchar(100) as
    update 表 set PHSum=stuff(PHSum,5,1,'8') where charindex(PHSum,@a)>0
      

  6.   

    create proc aa @a varchar(100) as
    update 表 set PHSum=stuff(PHSum,5,0,'8') where charindex(PHSum,@a)>0
      

  7.   

    呵呵,楼主笔误.
    charindex参数位置反了.
      

  8.   

    不是,是这样charindex(left(PHSum,4),@a)>0
    谢谢,我越来越能和你想到一块去了
      

  9.   

    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
      

  10.   

    wgzaaa 不一定是第五信的, 因为是区号可能会有 010 021这样的
      

  11.   

    update 表
    set PHSum=stuff(PHSum,5,0,'8')
    where left(PHSum,4) in ('0573','0575','0579','0576')
      

  12.   

    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
      

  13.   

    问题解决了,用的是bill024(咖啡熊)的方法,加了一个Where条件结帖!