例如:有一字段name 
名字一
名字二
名字三
.
.
.如何把 "名字一" 修改为 "一"
也就是把 "名字" 两个字去掉

解决方案 »

  1.   


    update tb set 字段=replace(字段,'名字','')
      

  2.   


      update 表A set name = replace(name,'名字','')
      

  3.   

    update 表A set name = Stuff(name,1,2,'')
      

  4.   


    update tb set [name]=replace([name],'名字','')
      

  5.   


    declare @table table (name varchar(6))
    insert into @table
    select '名字一' union all
    select '名字二' union all
    select '名字三'--如果名字2个字是固定的
    update @table
    set name=replace(name,'名字','')
    select * from @table
    /*
    name
    ------



    */declare @table1 table (name varchar(6))
    insert into @table1
    select '名字一' union all
    select '名字二' union all
    select '名字三'
    --如果2个字是不固定的,但是长度固定
    update @table1
    set name=substring(name,3,len(name))
    select * from @table1
    /*
    name
    ------



    */
      

  6.   

    --全部修改
    update tb set col = replace(col , '名字' , '')
    --只修改名字一
    update tb set col = replace(col , '名字' , '') where col = '名字一'