CREATE FUNCTION [dbo].[StripAllTags]( @input VARCHAR(8000))RETURNS VARCHAR(8000)ASBEGIN declare @Result varchar(8000), @start int, @end int, @len int set @input = @input+'<>' set @Result = '' set @len=len(@input) set @start = charindex('<',@input,1) set @end = charindex('>',@input,@start) while(@start<@end) begin if(@start<>1) set @Result = @Result + substring(@input,1,@start-1) set @len = @len - @end set @input = substring(@input,@end+1,@len) set @start = charindex('<',@input,1) set @end = charindex('>',@input,@start) end RETURN replace(@Result,' ','') END
//
调用
select dbo.StripAllTags('<td>调用</td>') 必须加上dbo,否则报“'StripAllTags' 不是可以识别的 内置函数名称”错误。