SqlServerNinja (4/11/2013)
Hi Sean,Thank you for your reply. This is the second time you are helping me out.
I actually see that there is
<?xml version="1.0" encoding="utf-16"?>
part in the xml. This is what is causing the error.
Once I remove this from the xml I dont see the error.
But I wanted to know if we can convert the xml without
removing this part of the xml.
That is exactly what I thought. You took XML that is encoded as UNICODE and stuck it into a non-UNICODE datatype (varchar). To get around this you will have to first cast your non-UNICODE datatype to a valid UNICODE type.
Something like this should work.
select CAST(CAST(ProductXML as nvarchar(max)) as XML) from TableA;
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/