Unable to cast TEXT to XML in SQL Server

后端 未结 6 775
自闭症患者
自闭症患者 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条回答
  •  旧时难觅i
    2020-12-25 11:31

    Have you tried CONVERT instead of CAST?

    SELECT CONVERT(XML, @xml).value('(/Record/UserGuid)[1]', 'NVARCHAR(max)')
    from tbl_Module_RequestForms_Items
    

    Also, check out the "xml styles" section of this page; it contains some options you have when converting xml:

    http://msdn.microsoft.com/en-us/library/ms187928.aspx

提交回复
热议问题