attachment - sp_send_dbmail inserts line-breaks into the attached xml query result -


When you send a query result in the form of a msdb.dbo.sp_send_dbmail You must provide the @query_result_width parameter, which is an integer between 10 and 32767.
Now, if you use the root ('data') for the XML path ('line'), type in your most-external selection query , you can use the XML Exchanges Send_dbmail for sending, which is easy to open in Microsoft Excel (only 2 or 3 clicks and this is a good Excel table)
However, if your XML file is more than 32767 bytes, send_dbmail xml file Put a "line-break" on the first row of 32767th column Singing, and it does this strictly! It means that it does not care what is written there; It just breaks the line and therefore will corrupt your XML data ... I have been roaming the internet for more than 5 hours and have not got any positive results from how I sp_send_dbmail from that dirty line-break injection Stop I had come to the sole solution that was injecting the line-break, where I was in control and it is not after the 32767th pillar. A query will be performed like the following, but this is extra work and is not clear ...

  choose the replacement (cast (choose (* from the table for the XML path ('line') NVarChar (Max) as the root ('data', type), N '/ & gt;' N '/ & gt; & lt;! - This is a controlled line-break. Remove this comment - & Gt; ')  

Anyone have a better idea? Am I missing something here?
I use SQL Server 2008 Enterprise (x64)


Comments