update tbl set text字段=replace(cast(text字段 as varchar),'你们好','您们好')

解决方案 »

  1.   

    mm--->朱艳飞 ??? 来冒充的吧。  :D
      

  2.   

    --如果是小于8000的字符号,可以如楼上简单替换下就可以了。
    update 
        @t 
    set s=replace(cast(s as varchar),'你们好','您们好')--大于8000处理如下:
    /*--------------------------------------------------------
    使用UPDATETEXT结合游标实现批量替换字段为TEXT类型的指定内容
    --------------------------------------------------------*/
    /*--------------------------------------------------------
    程序说明:
    通过游标来实现个字段(类型为text或ntext)里指定内容的替换
    其中
    @otxt变量为:要替换掉字符串值
    @ntxt变量为:替换的新字符串值
    请按需求更改!
    TargetField为该字段的名称
    TargetTable为数据表名称
    以下为整个程序(请按需更改)
    --------------------------------------------------------*/
    declare curs cursor local fast_forward
    for
    select 
    id,
    textptr(字段),
    charindex(@otxt, 字段)-1
    from 

    where 
    字段 
    like 
    '%' + @otxt +'%'
    declare @ntxt varchar(1000)
    set @ntxt = '您们好'declare @txtlen int
    set @txtlen = len(@otxt)declare @ptr binary(16)
    declare @pos int
    declare @id int
    open cursfetch next from curs into @id, @ptr, @poswhile @@fetch_status = 0
    begin
    updatetext #.字段 @ptr @pos @txtlen @ntxt fetch next from curs into @id, @ptr, @pos
    endclose curs
    deallocate curs