首页 > 开发 > 综合 > 正文

存储过程替换text,ntext列中的字符串

2024-07-21 02:12:11
字体:
来源:转载
供稿:网友

/*
author:amjn
date:2003-03-28
version:1.0
function:替换text,ntext列中的字符串(不支持中文)
*/
declare @ptr varbinary(16)
declare @amjnid int
declare @position int,@len int
set @len=datalength('ilovehjl')  
declare wux_cursor scroll cursor
for
select textptr([name]),[amjnid] from usa201
for read only
open wux_cursor
fetch next from wux_cursor into @ptr,@amjnid
while @@fetch_status=0
begin
  select @position=patindex('%ilovehjl%',[name]) from usa201 where [amjnid][email protected]
  while @position>0
  begin
    set @[email protected]
    updatetext usa201.[name] @ptr @position @len 'i love hjl'
    select @position=patindex('%ilovehjl%',[name]) from usa201 where [amjnid][email protected]
  end
  fetch next from wux_cursor into @ptr,@amjnid
end
close wux_cursor
deallocate wux_cursor
go


 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表