sp_send_dbmail - need new lines in body

CIC Admin
CIC Admin used Ask the Experts™
on
I am using sp_send_dbmail and it is working fine.  I want to add some additional text into the @body parameter.  Is there a way to a insert a couple of blank lines to separate this new text?   Maybe a control code or something.

I know I can set the body_format parameter to HTML and insert <br> statements, but i would like to avoid that if possible.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sr Database Engineer
Commented:
something like this?

declare @body varchar (100)
set @body = 'body' + char(13) +   char(13)  + 'another line'

EXEC msdb.dbo.sp_send_dbmail @profile_name = 'MailProfileName'
                  ,@recipients = 'email@domain.com'
                  ,@body = @body
                  ,@subject = 'test'
CHAR(10) for CRLF and CHAR(13) for LF
Here we go.
DECLARE @TEXT AS VARCHAR(100)
SELECT @TEXT = 'THIS IS COOL'+CHAR(10)+'BUT THIS IS EVEN COOLER'
PRINT @TEXT

SELECT @TEXT = 'THIS IS COOL'+CHAR(13)+'BUT THIS IS EVEN COOLER'
PRINT @TEXT

Open in new window

Author

Commented:
Thanks, that worked perfectly.  I was missing the fact that i needed to declare and set the variable above rather than directly in the EXEC statement.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial