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


Difficulties to use sp_send_dbmail with @@SERVERNAME


Difficulties to use sp_send_dbmail with @@SERVERNAME

Author
Message
vincent.D_FR
vincent.D_FR
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 134
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 !
Sowbhari
Sowbhari
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2088 Visits: 1486

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'


vincent.D_FR
vincent.D_FR
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 134
many thanks Smile
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