Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

db_Mail Syntax error message when attempting to pass variable to @Body

$
0
0
To all:For some reason, when I attempt to add a variable to the string of my @Body I get them error message Incorrect syntax near '+'. Here is my code, any suggestions are appreciated in advance! DECLARE @CRLF varchar(10), @EmailTo varchar(100) SET @EmailTo = 'rhayward@autopartintl.com' SET @CRLF = char(13) + char(10) EXEC msdb..sp_send_dbmail @Profile_name = 'Reporting', @Recipients = @EmailTo, @Subject = 'Test', @Body = '**** This is an automated email - Please do not respond to this message. ****' + @CRLF + 'The enclosed file contains...', @execute_query_database = 'myDB', @Query = 'SELECT * FROM TEST WHERE Err IS NOT NULL', @attach_query_result_as_file = 1, @query_attachment_filename = 'TestRept.csv' PRINT @Body

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images