'Conversion from xml to int is not supported on the connected database server'

  • I have a blank table with one xml column.

    I am changing the datatype from xml to int then it is giving error:

    'Conversion from xml to int is not supported on the connected database server'

    Any Idea?

    Thanks

  • XML is a binary data type so it has to de-serialized into a string before it can be cast to a numeric type.

    Works because SQL Server XML data types support fragments:

    SELECT CAST('1' AS XML)

    Does not work *

    SELECT CAST(CAST('1' AS XML) AS INT)

    Works:

    SELECT CAST(CAST(CAST('1' AS XML) AS VARCHAR(100)) AS INT)

    * See "Implicit Conversions" section for map of supported implicit and explicit conversions http://msdn.microsoft.com/en-us/library/ms187928.aspx

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Thanks,

    I was trying it from GUI!!

    Using command it works!!

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply