Questions:
I want to send custom email notification to specific groups/users for reporting purpose on daily basis. How can I send the data that i got from my dynamic select query as an attachment? Thanks!
Answers:
I would assume that you already have current SQL Agent/Job with Database Mail configured. If not, please follow the tutorial here; Configure Database Mail SQL Server. Otherwise, it won't send out any email notifications as expected.
1. To create an attachment, we need the data. Open MSSQL and open/prepare your select scripts. It might look something like this.
Notes: This is just an example |
2. Now, let's put this select script into our email sending command. Change the profile name, recipient, subject, body and attachment name accordingly.
3. Tadaaa, then you can set the SQL Job schedule as required. Easy!
Related Entries
SQL: How to send custom HTML email notification with MSSQL?