How do I convert an XML field with more than 8000 characters into a string?

Dxxz

New Member
I have a SQL Server column of type \[code\]XML\[/code\] containing some records with more than 8000 characters.I would like to convert this column into a \[code\]varchar\[/code\].I am not concerned about truncation (the first 8000 characters is fine).However, whenever I try \[code\]CONVERT(varchar(8000), Content)\[/code\] I get an error:\[quote\] Target string size is too small to represent the XML instance\[/quote\]When I try \[code\]CONVERT(varchar(MAX), Content)\[/code\] I get an error:\[quote\] String or binary data would be truncated\[/quote\]When I try \[code\]CONVERT(varchar(20000), Content)\[/code\] I get an error:\[quote\] The size (20000) given to the type 'varchar' exceeds the maximum allowed for any data type (8000)\[/quote\]When I try \[code\]CONVERT(text, Content)\[/code\] I get an error:\[quote\] Explicit conversion from data type xml to text is not allowed\[/quote\]Is there a workaround?
 
Back
Top