AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > SQL Server

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

51自学网 http://www.wanshiok.com
/*
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

 

 

 
上一篇:关于SQL Server中几个未公布的访问注册表的扩展存储过  下一篇:存储过程编写经验和优化措施