XML parsing unable to switch the encoding
When i tried to query a ntext column as xml with CAST function i had : XML parsing: line 1, character 55, unable to switch the encoding error. i did some research finally i succeed on it Ex : SELECT colum1, column2, CAST ( REPLACE ( CAST (column3 AS NVARCHAR ( MAX )), 'utf-8','utf-16' ) AS XML ) FROM TABLE1 column3 : is ntext xml data which has at the top of root element 1. Convert ntext to nvarchar for replace function (doesn't accept ntext datatype) 2. Replace 'utf-8' text with 'utf-16' because of SQL Server 2005 restrict 3.Cast result to XML and have fun :)