SQL Server Database Free Space

Many people like to customize the database (and transaction log) free space alerts and this is a script that can be used to help do that. Feel free to edit the script as needed for your environment. This script loops through all databases in an instance to collect free space data and then returns it back to the alert in DPA. The query returns 2 columns: 1) the message about the database/tlog and 2) the free space percent.

Note: this script only checks free space for database files that have a max size configured. If max size is configured as unlimited, monitor the disk free space instead as that will be the limiting factor.

To implement the alert, create a Custom SQL Alert of type Multiple Numeric return and make it look similar to this. Copy/paste the code from the attached script into the SQL Statement field: