Created
March 2, 2018 16:58
-
-
Save richardbasile/c69ef5970c9e59a8da72b2559e562bad to your computer and use it in GitHub Desktop.
SQL Server - File Sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH files AS ( | |
select name | |
, filename | |
, size | |
, fileproperty ( name, 'SpaceUsed' ) as used | |
from sysfiles | |
) | |
select name | |
, filename | |
, convert ( decimal ( 12, 2 ), size / 128.000 ) as FileSizeMB | |
, convert ( decimal ( 12, 2 ), used / 128.000 ) as UsedMB | |
, convert ( decimal ( 12, 2 ), ( size - used ) / 128.000 ) as FreeMB | |
from files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment