declare @old varchar(100)
declare @new varchar(100)
set @old='http://new.chaoren.com/CMS/localhost'
set @new='http://www.chaoren.com/CMS/localhost'
declare @ptr varbinary(16)
declare @newsid varchar(36)  --如为int则改为declare @newsid int
declare @Position int,@len int
set @len=datalength(@old)

declare yohen_Cursor scroll Cursor
for
select textptr([content]),[news_id] from t_news_content
where charindex(@old,content)>0 --and news_id='2007-06-08'
for read only

open yohen_Cursor
fetch next from yohen_Cursor into @ptr,@newsid
while @@fetch_status=0
begin
    select @Position=patindex('%' + @old + '%',[content]) from t_news_content where news_id=@newsid
    while @Position>0
    begin
    set @Position=@Position-1
    updatetext t_news_content.[content] @ptr @Position @len @new
    select @Position=patindex('%' + @old + '%',[content]) from t_news_content where news_id=@newsid
    end
    fetch next from yohen_Cursor into @ptr,@newsid
end
close yohen_Cursor
deallocate yohen_Cursor
go

相关文章:

  • 2021-09-01
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2021-07-21
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案