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

发布时间:2010年01月27日      浏览次数:662 次
/*
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]=@amjnId
   while @Position>0
   begin
     set @Position=@Position-1
     updatetext USA201.[Name] @ptr @Position @len 'i love hjl'
     select @Position=patindex('%ILOVEHJL%',[Name]) from USA201 where [amjnId]=@amjnId
   end
   fetch next from wux_Cursor into @ptr,@amjnId
end
close wux_cursor
deallocate wux_cursor
go
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!