...
Create SQL job
Paste code below
Update code as needed
Ensure Database mail is setup and referenced in the below code as profile name
schedule as needed, at least 30 minutes after the job that actually generates the report to give it time to generate
Code Block --Deferred Revenue Report USE msdb EXECUTE AS USER = 'dbo' EXEC msdb.dbo.sp_send_dbmail @recipients=N'test@test.com', @body='See text attachment for deferred revenue report', @subject ='Deferred Revenue report', @profile_name ='SMTP', @query ='select * from ViewDeferredRevenueReport order by id desc', @attach_query_result_as_file = 1, @query_attachment_filename ='deferredrevenuereport.txt'[cce]