ProgrammingBaKa ProgrammingBaKa -3 years ago 105
SQL Question

sp_send_dbmail set 2 queries for the @query parameter

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 !!

Answer Source

I tried . It did work, but the result was in same file. Not sure if thats what you want. Plus the number of rows is also an issue. Or error as follows is shown:

 Msg 22050, Level 16, State 1, Line 0
File attachment or query results size exceeds allowable value of 1000000 bytes.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download