Syntax error with @Query parameter in e-mail with select statement
Posted on 2007-07-20
Cast question in a @query statment for e-mail.
exec msdb..sp_send_dbmail --@recipients = @copymembers,
@profile_name = 'Mail Test',
@recipients = 'email@example.com',
@body = 'The following error(s) need to be investigated: ',
@query = 'select * from dbProcess..tbNumOfFilesinDirectories where fdUpdateDate =' + cast(@DateTime as varchar),
@Subject = 'Action: dbProcess..tbNumOfFIlesinDirectories Error(s) Need Investigation.'
Incorrect syntax near '+'.
I tried numerous set ups with moving quotes around and put () around entire statement and I can't get the error to go away. Sorry, I am a beginner and getting frustrated.