create function [dbo].f_FilterHtml( @vstrIn varchar(8000) ) returns varchar(8000)
as
begin
declare @str varchar(8000)
declare @p1 int
declare @p2 int
select @str=@vstrIn
set @str = replace(@str,'''','''''')
set @str = replace(@str,' ','')
set @str = replace(@str,'?','')
while charindex('<',@str)>0 and charindex('>',@str)>0
begin
set @p1 = charindex('<',@str)
set @p2 = charindex('>',@str)
set @str = substring(@str,1,@p1-1) + substring(@str,charindex('>',@str)+1,len(@str)-@p2)
end
return @str
end
调用方式:
select content,dbo.f_FilterHtml(content) content from dbo.money_news