国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

模擬字符串處理函數 stuff 處理 Ntext 字段

2024-07-21 02:07:48
字體:
來源:轉載
供稿:網友

if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[p_stuff]') and objectproperty(id, n'isprocedure') = 1)drop procedure [dbo].[p_stuff]go

/*--ntext字段處理

 模擬字符串處理函數 stuff 完成表中 ntext 字段的 stuff 處理 注意,表中需要有列名為:id 的主鍵(或標識字段),數據類型為int 如果沒有這個主鍵字段,或者是其他類型,則對應的需要修改存儲過程

--鄒建 2004.07--*/

/*--調用示例

 --測試數據 create table tb(id int identity(1,1),content ntext) insert tb select 'a;sd' union all select 'a;sdfkjas2qasdfdfsg45yhjhdfg45645a'  --調用存儲過程,將第8~9的字符替換成'中國' exec p_stuff 'tb','content',8,2,'中國','' select * from tb  drop table tb--*/

create proc [email protected] sysname, --要處理的表名@fdname sysname, --text/ntext字段名@start int=null, --開始位置,null表示追加數據@length int=null, --替換的長度@str nvarchar(4000),--要插入的字符串@where nvarchar(1000)=''--要處理的記錄的條件asif @str is null returndeclare @s nvarchar(4000)set @s='declare @id int,@ptr varbinary(16),@start1 int

declare tb cursor local for select id,start=datalength(['[email protected]+'])/2from ['[email protected]+']'+case isnull(@where,'') when '' then ''  else ' where '[email protected] end+'

open tb fetch tb into @id,@start1while @@fetch_status=0begin select @ptr=textptr(content)  from ['[email protected]+'] where [email protected]

 if @start is null or @start1<@start  updatetext ['[email protected]+'].['[email protected]+'] @ptr null null @str else begin  set @[email protected]  updatetext ['[email protected]+'].['[email protected]+'] @ptr @start1 @length @str end fetch tb into @id,@start1endclose tbdeallocate tb'exec sp_executesql @s ,n'@start int,@length int,@str nvarchar(4000)' ,@start,@length,@strgo

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黑河市| 石首市| 北海市| 唐海县| 阳曲县| 格尔木市| 昌吉市| 日照市| 眉山市| 新龙县| 莱芜市| 获嘉县| 安远县| 平果县| 广汉市| 日土县| 西畴县| 巴中市| 华蓥市| 扎鲁特旗| 浦江县| 根河市| 巴彦县| 和龙市| 渝北区| 资溪县| 手机| 延边| 新宁县| 新宾| SHOW| 辽宁省| 上高县| 邳州市| 昌乐县| 呼伦贝尔市| 龙游县| 镇雄县| 辽宁省| 无锡市| 滁州市|