sql text类型内容替换

来源:互联网 发布:labtool48uxp软件下载 编辑:程序博客网 时间:2024/06/06 09:17

declare @ID int
declare @strtmp varchar(max or 8000)
declare @strold char(old_length),@strnew char(new_length)
set @strold = 'oldChar'
set @strnew = 'newChar'
declare replace_Cursor scroll Cursor
for
select id from current_table
open replace_Cursor
fetch next from replace_Cursor into @ID
while @@fetch_status=0
begin
    select @strtmp = [current_content] from current_table where id=@ID
    select @strtmp = Replace(@strtmp,@strold,@strnew)
    update current_table set [current_content] = @strtmp where id=@ID
    fetch next from replace_Cursor into @ID
end
close replace_Cursor
deallocate replace_Cursor
go

原创粉丝点击