How to send Disk space report daily by a Job

Scenario

Send Disk space report daily by a Job. Here we will use a TSQL script for the activity. The script will create two temporary tables for the activity and use the Database mail to send the report via email.

Steps

1) First Configure Database mail in SQL Server if it is not configured before. You can follow the link for instruction: https://www.ourtechideas.com/blog/configure-database-mail/

2) Create a Job for the activity & schedule as per your requirement

3) Modify the script & use it in the Job

  • Must modify in the script
    • Email Sender Name
    • DB Mail Profile
    • Recipients Email
    • Copy Recipients Email

TSQL Script

Enabling xp_cmdshell & database Mail XPs

 

TSQL Script is collected from internet, 100% working

Download TSQL: DISK_SPACE_REPORT_VIA_EMAIL

Result

Facebook Comments Box

Comments

  • Hello Sanjay,
    I have created agent job for daily Disk space report using this script. The job was running fine but now the job is failing with error message. Could you help me how to solve this problem?

    Configuration option ‘show advanced options’ changed from 1 to 1. Run the RECONFIGURE statement to install.
    Configuration option ‘xp_cmdshell’ changed from 1 to 1. Run the RECONFIGURE statement to install.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Database name ‘Tempdb’ ignored, referencing object in tempdb.
    Msg 8134, Level 16, State 1, Line 74
    Divide by zero error encountered.
    Mail (Id: 5504) queued.

    Completion time: 2022-06-01T08:57:44.3743293-04:00

Leave a Reply

Your email address will not be published.