Unable to cast TEXT to XML in SQL Server

后端 未结 6 792
自闭症患者
自闭症患者 2020-12-25 10:36

Basically I have a column named XML that is of type TEXT; this cannot be changed for other reason, but I was wondering how I could cast it to XML.<

6条回答
  •  长情又很酷
    2020-12-25 11:30

    You need to change the encoding before casting to XML.

    CAST (REPLACE(MyTextToCastToXML, 'utf-8', 'utf-16') AS XML)
    

提交回复
热议问题