SQL SERVER – Available Free Space in Data and Log File

Lots of good feedback, I have received on my recent to the point blog posts. Today we will see a script for Available Free Space in Data and Log File.

SQL SERVER - Available Free Space in Data and Log File FreeSpace-800x359

Here is the script which you can run to identify the Total and Free space in your database files.

SELECT [File Name] = name,
[File Location] = physical_name,
[Total Size (MB)] = size/128.0,
[Available Free Space (MB)] = size/128.0
- CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0,
[Type] = type_desc
FROM sys.database_files;

Well, that’s it. We are done. You run the script above and it will give you available free space in data and log files for your current database. If you have any other questions or comments, you can reach out to me via comment.

Is your SQL Server running slow and you want to speed it up without sharing server credentials? In my Comprehensive Database Performance Health Check, we can work together remotely and resolve your biggest performance troublemakers in less than 4 hours.

If you liked this blog, please do not forget to subscribe to my YouTube Channel – SQL in Sixty Seconds.

Here are my few recent videos and I would like to know what is your feedback about them.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Quest

SQL Log, SQL Scripts, SQL Server
Previous Post
SQL SERVER – Rename View
Next Post
SQL SERVER – List Tables with Size and Row Counts – Part 2

Related Posts

1 Comment. Leave new

  • Really interested to know why you have written the SQL in this old-school fashion of [Alias] = column rather than column as [Alias] ?

    Reply

Leave a Reply