[标量函数] Html标记过滤 - HtmlFilter
/****** Object: UserDefinedFunction [dbo].[HtmlFilter] Script Date: 11/30/2010 14:39:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: MK -- Create date: 2010-11-30 -- Description: 去除Html标记 -- ============================================= CREATE FUNCTION [dbo].[HtmlFilter] ( @INPUT VARCHAR(MAX) ) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @A INT; DECLARE @B INT; DECLARE @S VARCHAR(MAX); SET @S = @INPUT; WHILE CHARINDEX('<', @S, 0) > 0 BEGIN SET @A = CHARINDEX('<', @S, 0); SET @B = CHARINDEX('>', @S, @A); IF @B < 1 SET @S = SUBSTRING(@S, 0, @A); ELSE SET @S = SUBSTRING(@S, 0, @A) + SUBSTRING(@S, @B + 1, LEN(@S) - @B); END RETURN @S; END GO