Question: How can I generate sql query results and attach to an email? I’d prefer to use the built in SQL Server Database Mail application Answer: To generate query results and attach to an email is easy through Database Mail. Use the sp_send_dbmail arguments @query and @attach_query_result_as_a_file. Note: You must use the value 1 , such as @attach_query_result_as_a_file = 1 This example executes a query based on details in the @query argument and attaches the output to an email EXEC msdb.dbo.sp_send_dbmail @recipients=N'[email protected]', @body= 'Some text for body', @subject = 'Some text for subject', @profile_name = 'MyProfile1', @query = ‘select name... Read more →