Server Drive Space Monitoring

This stored procedure can be used to monitor the amount of free disk space (in MiB) on a server and send an email alert when the free disk space drops below a defined threshold.

Input parameter @UNCPath is the UNC path for the drive. eg. \\servername\drive$

Returns free disk space in MiB.
A value of -1 means no drive exists.




The account running the stored procedure must have administrative access to the drive.
Database mail must be set up.
Access to run xp_cmdshell must be granted.

Suitable For:

2005, 2008


Install the stored procedure in master or other suitable database.

Example Script:

You can use the following example in a recurring SQL Job...