For XML Path Returning amp when '&' symbol used in text

  • Hello there, 

    I've attempted to find some information on the XML path and after a few modifications I still wasn't able to adjust this subselect statement to print the '&' symbol instead of the interpreted &amp. The code is below and any ideas would be great! Thanks🙂

     ((SELECT  ' ' + tddesc
               FROM    timedesc
               WHERE  (timecard.tindex = tindex) order by tdline asc FOR XML PATH('')), 2, 1000) AS time_desc

  • Those table names look horribly familiar...

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • If you change the 'FOR XML' part of your query to look like this:

    FOR XML PATH (''), TYPE).value('.','varchar(max)')

    you may find what you're looking for.

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • ThomasRushton - Tuesday, May 29, 2018 7:03 AM

    If you change the 'FOR XML' part of your query to look like this:

    FOR XML PATH (''), TYPE).value('.','varchar(max)')

    you may find what you're looking for.

    Add the text() function to prevent the construct of XML for the output, can half the work.

    FOR XML PATH (''), TYPE).value('(./text())[1]','varchar(max)')

  • Thanks to both of you for the guidance! Much appreciated.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply