I'm having a similar problem. My query is as follows:SELECT CI.EOVID as "@EOVid", CI.DefName as "@DefinitionName", (CONVERT(varchar(max),( SELECT CAST('<' + REPLACE(UsefulColumnName, ' ','') + '>' + REPLACE( REPLACE( REPLACE(ColumnValue,'<','') ,'>','') ,'&','+') + '</' + REPLACE(UsefulColumnName, ' ','') + '>' + CHAR(13) + CHAR(10) AS XML) FROM #ContentItemParts CIP WHERE CI.EOVID = CIP.EOVID FOR XML PATH(''), TYPE))) FROM #ContentItems CI FOR XML PATH('Root'), ROOT('ContentItems');
I am not getting any line breaks in the resulting XML. The problem is that if no line breaks are generated then they are automatically added after a particular length causing the XML to be corrupt. In otherwords I'm getting line breaks in random locations and not after an XML node. Any ideas on how to get these intentional line breaks to show or any alternatives?