unable to switch the encoding error with XML Data type
If you ever tried to cast string to XML data type in SQL Server then you may encounter this error
select cast(xmldata as XML) from XMLFiles
Msg 9402, Level 16, State 1, Line 1
XML parsing: line 1, character 54, unable to switch the encoding
Solution is simple. Just convert UTF-8 to UTF-16 as below
select cast(Replace(xmldata,'UTF-8', 'UTF-16') as XML) from XMLFiles
Leave a Reply
You must be logged in to post a comment.