Find the Drive Space,free and percentage Using T-SQL in SQL Server

Spread the love


xp_fixeddrives only provide how much disk space is free on each drive but not the maximum space of the drive & percentage of free space. If you need to find out Drive Space for SQL server with Drive Space, Free space and percentage of free space then we need to create a stored procedure ‘sp_diskspace‘.

Ole Automation Procedures

But !!!! before that, you need to enable Ole Automation Procedures feature. Ole Automation Procedures feature must be disabled unless specifically required and approved. To more about visit:

To enable Ole Automation Procedures feature we may follow below steps

Ole Automation Procedures is enabled.


Now we will create ‘sp_diskspace’ with the below script.

Download sp_diskspace in txtsp_diskspace in zip 

After successfully execution below messages will appear.

And we can also find the stored procedure in the MASTER database.

To run that stored procedure we need to execute below query

The result will be displayed like below snapshot.

Same output by a script

Now if you don’t want all this HUNGAMA!! of creating store procedures and enabling  Ole Automation Procedures feature then another simple solution is waiting for you. We can also get our desire result by running a simple script also. Simply run the below script. But the disadvantage is that below script will display only that disk status which contains only SQL Server files/data.


Spread the love
Author: OTi
Meet OTi, the brains behind the popular tech blog "" OTi is an accomplished author, tech enthusiast, and an expert in SQL Server. With over a decade of experience in the tech industry, he has become a trusted voice in the world of database management. OTi's passion for technology began at a young age, and he has been tinkering with computers ever since. He graduated with a degree in Computer Science and has since worked for some of the biggest tech companies in the world. His experience has given him a deep understanding of how technology works and how it can be used to improve our lives.

3 thoughts on “Find the Drive Space,free and percentage Using T-SQL in SQL Server

  1. Pingback: Amir

Leave a Reply

Your email address will not be published. Required fields are marked *