I have the following xml:
<?xml version="1.0" encoding="utf-8"?>
<products>
<product>
<ProductDescription><![CDATA[SOMETHIN''WHATEVER]]></ProductDescription>
</product>
<product>
<ProductDescription><![CDATA[TYPICAL_TEXT ΜΑΣΚΑΡΑ]]></ProductDescription>
</product>
</products>
which I want to make into columns. By searching around, I arrived at the following solution:
declare @input XML='copy-paste-my-xml'
SELECT
Item.value('(ProductDescription)[1]', 'nvarchar(max)') as ProductDescription
from
@input.nodes('//product') AS T(Item)
Running the query produces this error:
Msg 9420, Level 16, State 1, Line 1 XML parsing: line 9, character 57, illegal xml character
The place indicated by the error is where the first Unicode character starts: ΜΑΣΚΑΡΑ
. I deduce this because removing the unicode part makes the query run succesfully. But I've read that xml supports unicode. I also tried using N' but I got:
Msg 9402, Level 16, State 1, Line 1 XML parsing: line 1, character 38, unable to switch the encoding
What should I do to get the unicode value?
'xml here'
. Have you tried putting in a Unicode string:N'xml here'
? – Richard