I am writing this post on the demand of one reader.
In this post, I provide you one SQL Script to find free and occupied space for database storage files.
Actually SSMS provides GUI to find free and occupied space for individual Database.
But I am providing this script for the DBA reports where the DBA can use this column value in its reports.
Below is a script:
,CONVERT(DECIMAL(12,2),ROUND(Size/128.000,2)) AS FileSizeInMB
,CONVERT(DECIMAL(12,2),ROUND(FILEPROPERTY(Name,'SpaceUsed')/128.000,2)) AS UsedSpaceInMB
,CONVERT(DECIMAL(12,2),ROUND((Size-FILEPROPERTY(Name,'SpaceUsed'))/128.000,2)) AS FreeSpaceInMB
,Name AS DatabaseName
,FileName AS FileName
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.