Shepwedd
asked on
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?
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
+ char(10) + char(13) + ...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the char(10) + char(13) didn't work?
char(10) + char(13) is not simple line break it inserts one free line.
char(13) + char(10) works as simple line break.
char(13) + char(10) works as simple line break.