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

Difficulties to use sp_send_dbmail with @@SERVERNAME Expand / Collapse
Author
Message
Posted Tuesday, February 4, 2014 3:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 14, 2014 3:17 AM
Points: 4, Visits: 54
Hi everyone,

I have some trouble with the sp_send_dbmail procedure.

I use the following code :
declare @Body varchar(500)

set @body = 'my text for server ' + @@servername

exec msdb..sp_send_dbmail
@subject = 'my_subject' ,
@recipients = 'my_email_adresse',
@query = @Body ,
@profile_name = 'my_profile'

But I have the following error :
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 504
Query execution failed: Msg 156, Level 15, State 1, Server [SERVERNAME], Line 1
Incorrect syntax near the keyword 'for'.


Do you know what I do wrong ?!

Thanks in advance !

Post #1537657
Posted Thursday, February 13, 2014 4:58 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 11:17 AM
Points: 1,102, Visits: 914
DECLARE @MailBody VARCHAR(500)
SELECT @MailBody = 'My text for server ' + @@SERVERNAME
EXEC MSDB..SP_Send_DBMail
@Subject = 'my_subject',
@Recipients = 'my_email_adresse',
@Body = @MailBody,
@Profile_name = 'my_profile'

Post #1541116
Posted Friday, February 14, 2014 8:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 14, 2014 3:17 AM
Points: 4, Visits: 54
many thanks :)
Post #1541627
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse