• I only meant to show the two characters that would be escaped when casting to the XML data type.

    Thanks for the code samples Solomon. I ran a few tests and the one difference between the XML data type and the FOR XML techniques that I saw as important to note is that the XML data type will not show the actual text in all cases, i.e. it escapes the left-angle bracket and ampersand characters as < and & respectively, which could prove to disqualify its usage some scenarios:

    As a side note, I did find the problem with the particular text that was tripping up the FOR XML method I showed above (code since amended)...I copied an incomplete code sample from sp_WhoIsActive and this is a lesson to me. I have added the code to my SQL Prompt snippets so I do not miss the TYPE again. In neglecting to provide TYPE in the FOR XML clause I left out the secret sauce that handles the escapable characters and delivers them as they exist in the text, as well as prevents them from causing XML parsing errors.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato