|
发表于 2020-1-18 14:36:01
|
显示全部楼层
create procedure p_SpIsExist(@vDjlxbm varchar(3),@vSpInfo varchar(8000),@vBm varchar(30),@iIsExist int output)
as
begin
select @iIsExist=count(*) from tbnote_check_order where charindex('|bmbegin|'+@vBm+'|bmend|', @vSpInfo)>0 and f_bmbm=@vBm and f_djlxbm=@vDjlxbm
end
create function fun_getspinfo(@vSpInfo varchar(8000))
returns varchar(8000)
as
begin
return(isnull(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(@vSpInfo,'|linebegin|',''),'|lineend|',''),'|bmbegin|',''),'|bmend|',''),'|ygbmbegin|',''),'|ygbmend|',''),''))
end
create function fun_DelBmSpyj(@vSpInfo varchar(8000),@vBm varchar(30))
returns varchar(8000)
as
begin
declare @w int
declare @len int
declare @line varchar(8000)
declare @s varchar(8000)
set @len=len(@vSpInfo)
if @len>0
begin
set @s=@vSpInfo
while @len>1
begin
if substring(right(@vSpInfo,@len),1,len('|linebegin|'))='|linebegin|'
begin
set @line=substring(@vSpInfo,len(@vSpInfo)-@len+1,charindex('|lineend|',right(@vSpInfo,@len))+len('|lineend|')-1)
set @w=charindex('|bmbegin|'+@vBm+'|bmend|',@line)
if @w>0 set @s=REPLACE(@vSpInfo,@line,'')
end
set @len=@len-1
end
end
else set @s=@vSpInfo
return isnull(@s,'')
end
--测试
declare @s varchar(8000)
set @s='fdssdf|linebegin|haha2007-1-1|bmbegin|001|bmend|hehe123|ygbmbegin|001|ygbmend|sdjklsd|lineend|123'
select dbo.fun_DelBmSpyj(@s,'001')
--result
fdssdf123
|
|