• Steve - Very nice solution! 🙂

    sgmunson (7/29/2015)


    EDIT: There's a need to replace the XML representation of the greater than symbol with the actual greater than symbol, but this forum doesn't appear to be able to display the ampersand gt semicolon, so I bolded the two locations where the first needs to be the ampersand one and the 2nd needs to be the greater than.

    You can actually avoid this by altering the syntax of your FOR XML to the following...

    FOR XML PATH (''), TYPE).value('.', 'NVARCHAR(MAX)')

    The updated syntax will also avoid any additional problems caused by the possibility of special characters within the text values themselves.