¡m¤À¨É¡n¦Û©w¨ç¼Æ§R°£HTML Tag | |
¦b¤½¥q¹J¨ì¤F¤@ӻݨD¡A
§âª¾ÃÑ®wùتºª¾ÃѤå¥ó¶×¥X¡A¨Ã¥Bn§R°£HTML Tag¡I
§R°£HTML Tag¨Ã¤£¦bSQL¤º«Øªºfunction¤¤¡A
³z¹Lºô¸ô§ä¨ì¤F¥H¤Uªº¦Û©w¸qfunction¥i¥h°£HTML Tag¡C
CREATE FUNCTION [dbo].[fn_StripHtmlTags]
(
@HTMLText NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
WHILE @Start > 0 AND @End > 0 AND @Length > 0
BEGIN
SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'')
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
END
RETURN LTRIM(RTRIM(@HTMLText))
END
©óDB¤¤³z¹L·s¼W¬d¸ß¡A«Ø¥ß¤F¦¹¦Û©w¸q¨ç¼Æ¡C
¦Û©w¸qªº¨ç¼Æ¥i¦bDB¤¤ªº¥iµ{¦¡©Ê¡÷¨ç¼Æ¡÷¯Â¶qȨç¼Æùاä¨ì¡C
¦Û©w¸q¨ç¼Æ«Ø¥ß«á¡A´N¥i¥H¦bSQLùعB¥Î¦¹¨ç¼Æ¤F¡C
SELECT dbo.fn_StripHtmlTags(K1.Content)
FROM t_knowledges AS K1
WHERE T1.FKnowledgeCatalogID=100
³o¼Ë¿é¥Xªº¤º®eùØ¡AHTML Tag´N³Q²¾°£¤F¡ã
♥¶¶¤l¦Ñ±Cªººô©ç¡A½Ð¦hÃö·Ó¡ã
If you don't like something, change it.
If you can't change it, change your attitude.
Don't complain!
|