程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> 存儲過程替換text,ntext列的字符串

存儲過程替換text,ntext列的字符串

編輯:關於SqlServer
 /*
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
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved