Created
March 31, 2021 09:07
-
-
Save HainanZhao/9ca86f3db9b7693425800d03b573766e to your computer and use it in GitHub Desktop.
Send Email in SQL server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| exec msdb.dbo.sp_send_dbmail | |
| @profile_name = 'EMAIL_PROFILE', | |
| @recipients = 'test@mailinator.com', | |
| @subject = 'email subject', | |
| @query = 'select * from table_name', | |
| @attach_query_result_as_file = 1, | |
| @query_result_header = 1, | |
| @query_attachment_filename = 'data.csv' | |
| End | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment