Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Can I insert today's date in an email? Expand / Collapse
Author
Message
Posted Monday, February 11, 2013 11:32 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 8, 2014 7:26 AM
Points: 18, Visits: 252
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)"
Post #1418583
Posted Monday, February 11, 2013 11:46 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 2:52 PM
Points: 3,971, Visits: 3,406
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
Post #1418588
Posted Wednesday, February 13, 2013 7:28 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 8, 2014 7:26 AM
Points: 18, Visits: 252
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
Post #1419511
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse