Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing carriage return or line feed to build message body with tsql
    text
    copied!<p>I have the following tsql that sends db mail. This works with one formatting exception. The last two lines generated do not have a line feed or carriage return in the email body. The data types are varchar(255) and varchar(300) respectively. </p> <p>I have tried with and with out cast and I have tried CHAR(10), CHAR(13) separately and together.</p> <p>Why does these last two NOT split into separate lines?</p> <pre><code> DECLARE @errMsg VARCHAR(max) -- review edit fact UMDNSID values and catch orphans with out parents in CategoryList select @errMsg = '====================================================================' + char(10) + 'Orphan UMDNSID: ' + cast(ef.umdnsid as varchar(50)) + char(10) + 'Edit Fact VendorItemID: ' + cast(ef.vendoritemid as varchar(50)) + char(10) + 'Current VendorItem UMDNSID: ' + cast(ip.umdnsid as varchar(50)) + char(10) + 'Current VendorItem Category: ' + ipcl.categoryname + char(10) + 'Item Description: ' + ef.LongDescription + char(10) + char(13) from EditFact ef join itemprovider ip on ef.vendoritemid = ip.itemprovider_pk join categorylist ipcl on ipcl.umdnsid = ip.umdnsid where 1=1 AND editstatusid = 0 AND settled is null AND ef.UMDNSID not in ( select umdnsid from categorylist) EXEC dbo.ProcessFile_SendMail @ProcessFile_id=0, @Subject='Orphan UMDNSID', @Message=@errMsg, @To='someone@email.com'; </code></pre> <p>The email body ends up looking like the following and I expect a new line where you see **.</p> <p>Orphan UMDNSID: 27854<br> Edit Fact VendorItemID: 4654178<br> Current VendorItem UMDNSID: 99936<br> Current VendorItem Category: Custom Packs **Item Description: TRAY CARDIAC CATH CUSTOM</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload