Shunze ¾Ç¶é >¹q¸£¸ê°T¾Ç¨t >¸ê®Æ®wºÞ²z > ¡m¤À¨É¡n¦Û©w¨ç¼Æ§R°£HTML Tag «¢Åo¡AÁÙ¨S¦³µù¥U©ÎªÌµn¤J¡C½Ð§A[µù¥U|µn¤J]
« ¤W¤@½g¥DÃD ¤U¤@½g¥DÃD » Åã¥Ü¦¨¦C¦L¼Ò¦¡ | ¼W¥[¨ì§Úªº³Ì·R
µoªí·s¥DÃD µoªí¦^ÂÐ
§@ªÌ
¥DÃD
shunze
¤u¤Í§B§B


µù¥U¤é´Á: 2002 04
¨Ó¦Û: ¼é¦Á²×¤î¤§¦a
¤å³¹: 2380

shunze Â÷½u
¡m¤À¨É¡n¦Û©w¨ç¼Æ§R°£HTML Tag¤Þ¥Î¦^ÂÐ ½s¿è/§R°£¤å³¹ ·j´M¥Ñ  µoªíªº¨ä¥L¤å³¹ ¦^³øµ¹ª©¥D IP ¦ì¸m ¦^¦¹­¶³Ì¤W¤è

¦b¤½¥q¹J¨ì¤F¤@­Ó»Ý¨D¡A
§âª¾ÃÑ®wùتºª¾ÃѤå¥ó¶×¥X¡A¨Ã¥B­n§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!




2012-11-08, 18:36 shunze ªº­Ó¤H¸ê®Æ §â shunze ¥[¤J¦n¤Í¦Cªí µo°eEmailµ¹ shunze ÂsÄý shunze ªººô¯¸ MSN : shunze@gmail.com
shunze
¤u¤Í§B§B


µù¥U¤é´Á: 2002 04
¨Ó¦Û: ¼é¦Á²×¤î¤§¦a
¤å³¹: 2380

shunze Â÷½u
¤Þ¥Î¦^ÂÐ ½s¿è/§R°£¤å³¹ ·j´M¥Ñ  µoªíªº¨ä¥L¤å³¹ ¦^³øµ¹ª©¥D IP ¦ì¸m ¦^¦¹­¶³Ì¤W¤è

ÁöµM¦¨¥\¥h°£¤FHTML Tag <¡B>¡A¦ýªÅ¥Õ¦r¤¸&nbsp;«oÁÙ¬O´Ý¯dµÛ¸Ó«ç»ò¿ì?

´N¥ÎSQL¥»¨­ªº¨ç¼Æreplace¨Ó§¹¦¨§a¡I

³z¹L

replace(string, '&nbsp;', '')

´N¥i¥H§â&nbsp;¥HªÅ¦r¦ê¨ú¥N±¼~

¦p¤W¨Ò¡A¥i­×§ï¬°¦p¤U
SELECT replace(dbo.fn_StripHtmlTags(K1.Content),'&nbsp;','')
FROM t_knowledges AS K1
WHERE T1.FKnowledgeCatalogID=100



♥¶¶¤l¦Ñ±Cªººô©ç¡A½Ð¦hÃö·Ó¡ã

If you don't like something, change it.
If you can't change it, change your attitude.
Don't complain!




2012-11-30, 17:02 shunze ªº­Ó¤H¸ê®Æ §â shunze ¥[¤J¦n¤Í¦Cªí µo°eEmailµ¹ shunze ÂsÄý shunze ªººô¯¸ MSN : shunze@gmail.com
  « ¤W¤@½g¥DÃD ¤U¤@½g¥DÃD »
µoªí·s¥DÃD µoªí¦^ÂÐ
¸õ¨ì:

Powered by: Burning Board 1.1.1 2001 WoltLab GbR