How do I reference a new line in sql for my database mail query?

Hi,

I have written the attached database mail query but I'm struggling to find the sql to reference a new line in my query. In the attached code I have tried '\n' but it doesn't seem to work. Can anyone help?
DECLARE @trust_subject NVARCHAR(100)
DECLARE @trust_message NVARCHAR(MAX)
SET @trust_subject = 'Trust System - Crucial Date Alert';
 
DECLARE  CursorTemplate CURSOR 
      FAST_FORWARD FOR       
      Select 
      'This is a reminder that the below crucial date is due exactly two months today:\n\nClient Name: ' + tt.ClientName + '\n\nMatter Number:' + tt.MatterNo + '\n\nPartner:' + tpl.PartnerDescription + '\n\nFee Exec:' + tfel.FeeExecDescription + '\n\nDue Date:' + CAST(cdtcd.DueDate as NVARCHAR) + '\n\nEvent:' + cdel.EventDescription
      From Trusts.Trusts tt INNER JOIN Trusts.PartnerLookup tpl ON tt.PartnerCode = tpl.PartnerCode INNER JOIN Trusts.FeeExecLookup tfel ON tt.FeeExecCode = tfel.FeeExecCode INNER JOIN CrucialDates.TrustCrucialDates cdtcd ON tt.TrustID = cdtcd.TrustID INNER JOIN CrucialDates.EventLookup cdel ON cdtcd.EventCode = cdel.EventCode
 
OPEN CursorTemplate
 
FETCH NEXT FROM CursorTemplate 
INTO      @trust_message
 
WHILE (@@FETCH_STATUS = 0)
BEGIN
	EXEC msdb.dbo.sp_send_dbmail
      @recipients = 'someone@somewhere.co.uk', 
      @body = @trust_message,
      @subject = @trust_subject
 
      FETCH NEXT FROM CursorTemplate 
      INTO      @trust_message
 
END
 
CLOSE CursorTemplate
DEALLOCATE CursorTemplate

Open in new window

ShepweddAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
+ char(10) + char(13) + ...
0
chapmandewCommented:
use that instead of the /n
0
pcelbaCommented:
Use CHAR(13) for line break or CHAR(13)+CHAR(13) for one free line

DECLARE  CursorTemplate CURSOR 
      FAST_FORWARD FOR       
      Select 
      'This is a reminder that the below crucial date is due exactly two months today:'+CHAR(13)+CHAR(13)+'Client Name: ' + tt.ClientName +CHAR(13)+CHAR(13)+'Matter Number:' + tt.MatterNo +CHAR(13)+CHAR(13)+'Partner:' + tpl.PartnerDescription +CHAR(13)+CHAR(13)+'Fee Exec:' + tfel.FeeExecDescription +CHAR(13)+CHAR(13)+'Due Date:' + CAST(cdtcd.DueDate as NVARCHAR) +CHAR(13)+CHAR(13)+'Event:' + cdel.EventDescription
      From Trusts.Trusts tt INNER JOIN Trusts.PartnerLookup tpl ON tt.PartnerCode = tpl.PartnerCode INNER JOIN Trusts.FeeExecLookup tfel ON tt.FeeExecCode = tfel.FeeExecCode INNER JOIN CrucialDates.TrustCrucialDates cdtcd ON tt.TrustID = cdtcd.TrustID INNER JOIN CrucialDates.EventLookup cdel ON cdtcd.EventCode = cdel.EventCode
 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chapmandewCommented:
the char(10) + char(13) didn't work?
0
pcelbaCommented:
char(10) + char(13) is not simple line break it inserts one free line.
char(13) + char(10) works as simple line break.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.