XML Special characters

  • DECLARE @t TABLE(a VARCHAR(100))

    INSERT @t SELECT 'abc' UNION ALL SELECT 'd<c>f' UNION ALL SELECT 'ghi'

    SELECT

    CAST(

    (SELECT a+',' FROM @t FOR XML PATH('')) AS XML

    ).query('/.[1]').value('.','nvarchar(200)')

    Would like to see abc,d<c>f,ghi as output

    Not abc, d & l t ; c & g t ; f,ghi,

    Thanks

  • My fault, actually working correctly.

    DECLARE @t TABLE(a VARCHAR(100))

    INSERT @t SELECT 'abc' UNION ALL SELECT 'd<c>f' UNION ALL SELECT 'ghi' UNION ALL SELECT '<">'

    SELECT

    CAST(

    (SELECT a+',' FROM @t FOR XML PATH('')) AS XML

    ).query('/.[1]').value('.','nvarchar(200)')

Viewing 2 posts - 1 through 1 (of 1 total)

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