CREATE FUNCTION [dbo].[fn_RemoveHtmlTag](@htmlTagWithHtml VARCHAR(MAX))RETURNS VARCHAR(MAX)AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@htmlTagWithHtml )SET @End = CHARINDEX('>',@htmlTagWithHtml ,CHARINDEX('<',@htmlTagWithHtml ))SET @Length = (@End - @Start) + 1WHILE @Start > 0AND @End > 0AND @Length > 0BEGIN
SET @htmlTagWithHtml = STUFF(@htmlTagWithHtml ,@Start,@Length,'')SET @Start = CHARINDEX('<',@htmlTagWithHtml )SET @End = CHARINDEX('>',@htmlTagWithHtml ,CHARINDEX('<',@htmlTagWithHtml ))SET @Length = (@End - @Start) + 1END
RETURN LTRIM(RTRIM(@htmlTagWithHtml ))ENDGO
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@htmlTagWithHtml )SET @End = CHARINDEX('>',@htmlTagWithHtml ,CHARINDEX('<',@htmlTagWithHtml ))SET @Length = (@End - @Start) + 1WHILE @Start > 0AND @End > 0AND @Length > 0BEGIN
SET @htmlTagWithHtml = STUFF(@htmlTagWithHtml ,@Start,@Length,'')SET @Start = CHARINDEX('<',@htmlTagWithHtml )SET @End = CHARINDEX('>',@htmlTagWithHtml ,CHARINDEX('<',@htmlTagWithHtml ))SET @Length = (@End - @Start) + 1END
RETURN LTRIM(RTRIM(@htmlTagWithHtml ))ENDGO
No comments:
Post a Comment