Friday, 20 June 2014

Replace Tab to Space in XML field of SQL Server

REPLACE(CAST([PassiveDataXML] AS NVARCHAR(MAX)), '\t', ' ') AS PASSIVEDATAXML

1. ERROR: com.microsoft.sqlserver.jdbc.SQLServerException: Conversion of one or more characters from XML to target collation impossible

you have some characters in your XML document that cannot be stored in that varchar column. Either the collation for that column is incorrect, or you need more flexibility in the value that you can store and it should be an nvarchar column instead.

2. ERROR: Target string size is too small to represent the XML instance

NVARCHAR(MAX)

Reference:
1. XML, String converting in SQL Server
https://www.simple-talk.com/sql/database-administration/converting-string-data-to-xml-and-xml-to-string-data/

No comments:

Post a Comment