SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can I insert today's date in an email?


Can I insert today's date in an email?

Author
Message
Tabbasum
Tabbasum
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 383
I have to set up a sql job that sends an email
suppose
"This is to test that today is 02/11/2013 and it is a good day"

EXEC msdb.dbo.sp_send_dbmail
@recipients = 'someone@yahoo.com,
@subject = 'Test',
@body =
'This is to test that today is 02/11/2013 and it is a good day'

Is there any way that whenever the job runs it puts the current date with
"SELECT CONVERT(VARCHAR(12),GETDATE(), 101)"
Ed Wagner
Ed Wagner
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16691 Visits: 10070
Unfortunately, SQL Server doesn't like to have concatenated stuff passed to parameters. So, you could do something like this:

declare @strBody varchar(255);

select @strBody = 'This is to test that today is ' + CONVERT(VARCHAR(12), GETDATE(), 101) + ' and it is a good day';

EXEC msdb.dbo.sp_send_dbmail
@recipients = 'someone@yahoo.com',
@subject = 'Test',
@body = @strBody;




Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Tabbasum
Tabbasum
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 383
Ed Wagner (2/11/2013)
Unfortunately, SQL Server doesn't like to have concatenated stuff passed to parameters. So, you could do something like this:

declare @strBody varchar(255);

select @strBody = 'This is to test that today is ' + CONVERT(VARCHAR(12), GETDATE(), 101) + ' and it is a good day';

EXEC msdb.dbo.sp_send_dbmail
@recipients = 'someone@yahoo.com',
@subject = 'Test',
@body = @strBody;



That was good. Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search