/* Split 函数*/
-- dbo.Split('a,b,c,d' , ',') --
Create Function [dbo].[Split]
returns @temp Table(item varchar(1000))
AS
end
End
GO
/** Split 另一种算法**/
Create function [dbo].[split_pic]
(
@pic varchar(2000),
@split varchar(2)
)
returns @t table(col varchar(200))
as
begin
while(charindex(@split,@pic)<>0)
begin
insert @t(col) values (substring(@pic,1,charindex(@split,@pic)-1))
set @pic = stuff(@pic,1,charindex(@split,@pic),'')
end
insert @t(col) values (@pic)
return
end
GO
/** 清除HTML代码 **/
-- dbo.ClearHtml( strHtml ) --
Create Function [dbo].[ClearHtml]
(
@maco varchar(max)
)
returns varchar(max)
AS
Begin
declare @randchar_one nvarchar(200)
declare @randchar_two nvarchar(200)
if(charindex('<<',@maco)>0)
begin
set @randchar_one='D4678B36-B958-4274-B81E-BBA636CFB427';
set @randchar_two='49E374CC-9E1A-4850-897C-27074DE32E7F';
set @maco=replace(@maco,'<<',@randchar_one)
set @maco=replace(@maco,'>>',@randchar_two)
end
declare @i int
while 1 = 1
begin
set @i=len(@maco)
set @maco=replace(@maco, substring(@maco,charindex('<',@maco),
charindex('>',@maco)-charindex('<',@maco)+1),space(0))
if @i=len( @maco )
break
end
set @maco=replace(@maco,' ','')
set @maco=replace(@maco,' ','')
set @maco=ltrim(rtrim(@maco))
set @maco=replace(@maco,char(9),'')
set @maco=replace(@maco,char(10),'')
set @maco=replace(@maco,char(13),'')
if(charindex(@randchar_one,@maco)>0)
begin
set @maco=replace(@maco,'D4678B36-B958-4274-B81E-BBA636CFB427','<<')
set @maco=replace(@maco,'49E374CC-9E1A-4850-897C-27074DE32E7F','>>')
end
return (@maco)
End