I want to send db mail , which contains the result of two queries, how do I make it happen?
USE msdb
EXEC sp_send_dbmail
@profile_name = 'try01',
@recipients = '[email protected]',
@subject = 'Table Values',
@body = 'xxxxxxxxxxxxxx.',
@execute_query_database = 'Reports',
@query = 'SELECT * from Table'
OK, This was easy as if you put a semicolon the result of both the queries are sent. Here it is:
USE msdb
EXEC sp_send_dbmail
@profile_name = 'try01',
@recipients = '[email protected]',
@subject = 'Table Values',
@body = 'xxxxxxxxxxxxxx.',
@execute_query_database = 'Reports',
@query = 'SELECT * from Table; select * from table2'
Only problem I have now is to get this into a decent looking format.