Search
 
SCRIPT & CODE EXAMPLE
 

HTML

html entity decode in sql query

DECLARE @htmlNames TABLE 
(
    ID INT IDENTITY(1,1), 
    asciiDecimal INT, 
    htmlName varchar(50)
);

INSERT INTO @htmlNames 
VALUES 
    (34,'"'),
    (38,'&'),
    (60,'<'),
    (62,'>'),
    (160,' '),
    (161,'¡'),
    (162,'¢')
;

DECLARE @inputString varchar(max)= '&test&quot;<String>"&';
DECLARE @resultString varchar(max) = @inputString;

-- Simple HTML-decode:
SELECT
    @resultString = Replace(@resultString COLLATE Latin1_General_CS_AS, htmlName, NCHAR(asciiDecimal))
FROM
    @htmlNames
;

SELECT @resultString;
-- Output: &test"<String>"&


-- Multiple HTML-decode:
SET @resultString = @inputString;

DECLARE @temp varchar(max) = '';
WHILE @resultString != @temp
BEGIN
    SET @temp = @resultString;

    SELECT
        @resultString = Replace(@resultString COLLATE Latin1_General_CS_AS, htmlName, NCHAR(asciiDecimal))
    FROM
        @htmlNames
    ;
END;

SELECT @resultString;
-- Output: &test"<String>"&
Comment

PREVIOUS NEXT
Code Example
Html :: how to put more than one javascript function in an html tag 
Html :: gambar internal html 
Html :: twig post 
Html :: macbook boot in verbose mode 
Html :: show title combox check box wpf 
Html :: html count django model related_name 
Html :: Open the image after clicking on the text with the effect in html 
Html :: run 2 function on input vue 
Html :: submit form include input type submit 
Html :: thml text are 
Html :: contact form 
Html :: create an html page in visual studio 
Html :: learn html 
Html :: div class wrapper html 
Html :: How to link Excel sheet to HTML page 
Html :: remove html between 2 tags javas 
Html :: navbar bootstrap 5 
Css :: htaccess for angular 
Css :: write text in one line css 
Css :: css position absolute middle 
Css :: remove styling from a tag 
Css :: remove blue border on a input 
Css :: responsive image in css 
Css :: create a specific form size and center in css 
Css :: css font text stroke 
Css :: css text dots 
Css :: how to cover full image in css 
Css :: css selector start with 
Css :: css fadeIn opacity transition 
Css :: text underline hover css 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =