update tableA set col = 'http://teo/hwweb/upload/xx.jpg(xx2.jpg)'   where col like '%http://teo/hwweb/upload/xx1.jpg(xx2.jpg)%'

解决方案 »

  1.   

    --Content是什么样的数据类型??
    --如果是varchar数据类型,直接替换就可以了
    --如果是Text数据类型,要用updatetext 一条一条循环处理--测试环境
    declare @TableA table(Content varchar(2000))
    insert into @TableA select 'http://teo/hwweb/upload/xx1.jpg(xx2.jpg)'
    --替换语句
    update @TableA set Content=replace(Content,'http://teo/hwweb/','../../')
    where patindex('%http://teo/hwweb/%',Content)>0
    --查看结果
    select * from @TableA
    --结果
    ../../upload/xx1.jpg(xx2.jpg)(所影响的行数为 1 行)
      

  2.   

    update TableA set content = replace(content,'http://teo/hwweb/','../../')
      

  3.   

    可以不直接在SQL语句中更换吗?只要你原来数据有规律就应该可以换,
    http://teo/hwweb/upload/xx1.jpg(xx2.jpg) 可以先找到最后一个/位置,再取得xx1.jpg文件名,再后面就容易了.........
      

  4.   

    --如果是:ntext--处理方式如下:declare @TableA table(Content ntext)
    insert into @TableA select 'http://teo/hwweb/upload/xx1.jpg(xx2.jpg)'update @TableA set Content=replace(convert(varchar(8000),Content),'http://teo/hwweb/','../../')
    where patindex('%http://teo/hwweb/%',Content)>0select * from @TableA--结果
    ../../upload/xx1.jpg(xx2.jpg)(所影响的行数为 1 行)
      

  5.   

    to: zlp321002
    可行,不过它将content中的一些换行符,退位符,回车符都变为???了.请问如何解决?2.还有一种情况,在asp.net后台程序中如何实现,即,过滤后..直接插入到数据库中...
    等待中,,,高人救急!
      

  6.   

    补充:将replace(convert(varchar(8000),Content),'http://teo/hwweb/','../../')
    改为:replace(convert(nvarchar(4000),Content),'http://teo/hwweb/','../../')
      

  7.   

    晕,还是不行,ntext超过了nvarchar(4000) varchar(8000),这样后面被截去了.