我有个content字段,是TEXT,大于8000
我现在要替换掉里面的http://www.cici.cn/cmsimages/为http://www.XXXX.cn
请问各位要怎么做啊?
谢谢,在线等,解决马上送分

解决方案 »

  1.   

    create table gg(id int,a Ntext)
    insert gg select 1,'a你sdf/newwebefewe82348iasoipdjfaslk;djfasl;djf;asdfas/2384k'declare @a binary(16)
    declare @p int
    select @a = TEXTPTR(a) from gg
    select @p=charindex('/newweb',a) from gg
    updatetext gg.a @a @p 7 ''a是Ntext,@p是int
      

  2.   

    --创建数据测试环境   
    create   table   #tb(content   text)   
    insert   into   #tb   select   'abc_http://www.cici.cn/cmsimages/_abc'   --定义替换的字符串   
    declare   @s_str   varchar(8000),@d_str   varchar(8000)   
    select   
    @s_str='http://www.cici.cn/cmsimages/'   --要替换的字符串 
    ,@d_str='http://www.XXXX.cn' --替换成的字符串   --字符串替换处理   
    declare   @p   varbinary(16),@postion   int,@rplen   int   
    select   @p=textptr(content),@rplen=len(@s_str),@postion=charindex(@s_str,content)-1   from   #tb   
    while   @postion>0   
    begin   
      updatetext   #tb.content   @p   @postion   @rplen   @d_str   
      select @postion=charindex(@s_str,content)-1   from   #tb   
    end--显示结果   
    select   *   from   #tb   --删除数据测试环境   
    drop   table   #tb   --结果
    /*
    content
    ------------------------------------------
    abc_http://www.XXXX.cn_abc
    */