Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create SQL job

  2. Paste code below

  3. Update code as needed

  4. Ensure Database mail is setup and referenced in the below code as profile name

  5. 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]