all
May i ask is it possible to set two queries for the stored procedure sp_send_dbmail?
For example:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'example',
@recipients = 'example@XXX.com',
@query = 'Select * from table1; Select * from table2;',
@subject = 'Example',
@attach_query_result_as_file = 1 ;
Since most of the example from the internet only contain one query for the @query parameter.
May i ask will the above code causing error?
Thanks a lot !!
EDIT:
After deployment, the script was result in error for the @query parameter defined.
The error message is shown below
Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed.
Solution:
Notice that when defining @query, the table should be in full path,
Hence:
@query = 'Select * from [YOUR_SERVER_NAME].[dbo].table1; Select * from [YOUR_SERVER_NAME].[dbo].table2;',