To email the results of a query, use the @query argument. To attach those results as an attachment, use the @attach_query_result_as_file argument. This is accepts a bit value, with the default being 0 (for no attachment). To send the results in an attachment, simply provide a 1 for this argument.
SQL Server provides an easy way to email the results of a query to yourself (or to someone else). To send email with T-SQL, you need to use the sp_send_dbmail stored procedure in the msdb database. This procedure accepts many arguments, one of which is the @query argument.
I have a result set from an Execute SQL Task
query saved on a System.Object variable and i would like to send this results using a Send Mail Task
using the following expression on the MessageSource.
"Please find attached data summary\n\n" + SUBSTRING( @[User::myVariable] ,1,3990)
+ "\n\n"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With