I'm trying to take a string in SQL Server that contains an accented character (the acute e specifically) and have it convert correctly when using FOR XML PATH as follows:
SELECT 'é' AS Accent FOR XML PATH('') /* Produces: <Accent>é</Accent> */ However, it always comes through with the accent, or tries to convert the other characters instead. This is what I've tried so far:
SELECT 'é' AS Accent FOR XML PATH('') /* Produces: <Accent>é</Accent> */ SELECT N'é' AS Accent FOR XML PATH('') /* Produces: <Accent>é</Accent> */ SELECT REPLACE('é', 'é', 'é') AS Accent FOR XML PATH('') /* Produces: <Accent>&eacute;</Accent> */ SELECT '<![CDATA[' + 'é' + ']]>' AS Accent FOR XML PATH('') /* Produces: <Accent><![CDATA[é]]></Accent> */ SELECT CAST('<![CDATA[' + 'é' + ']]>' AS XML) AS Accent FOR XML PATH('') /* Produces: <Accent>é</Accent> */ I've looked for quite a while and can't find anything apart from casting the end result XML into a string and manually replacing the character - I'm looking for a more correct way to do this. Is this just a bug in SQL Server? It seems to convert plenty of other characters (<, >, &, etc...).
Huge thanks in advance for any assistance.
I'm using SQL Server 2008.
<Accent>é</Accent>actually, but - for any reason - you need this to be<Accent>é</Accent>?