update 表名 set 字段2=replace(字段2,'XX','YY')

解决方案 »

  1.   

    declare @t table(字段1 int,字段2 varchar(20))
    insert into @t select 1,'aaaXXaaa'
    union all select 2,'bbbXXbbb'
    union all select 3,'cccXXccc'
    union all select 4,'dddXXddd'
    union all select 5,'eeeXXeee'update @t set 字段2=replace(字段2,'XX','YY') where charindex('XX',字段2)>0select * from @t??
      

  2.   

    update tablename set colname=replace(colname,'xx','yy')
      

  3.   

    --没必要用charindex
    declare @t table(字段1 int,字段2 varchar(20))
    insert into @t select 1,'aaaXXaaa'
    union all select 2,'bbbXXbbb'
    union all select 3,'cccXXccc'
    union all select 4,'dddXXddd'
    union all select 5,'eeeXXeee'update @t set 字段2=replace(字段2,'XX','YY')select * from @t