Skip to content

Instantly share code, notes, and snippets.

@richardbasile
Created March 2, 2018 16:58
Show Gist options
  • Save richardbasile/c69ef5970c9e59a8da72b2559e562bad to your computer and use it in GitHub Desktop.
Save richardbasile/c69ef5970c9e59a8da72b2559e562bad to your computer and use it in GitHub Desktop.
SQL Server - File Sizes
;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