Skip to content

Instantly share code, notes, and snippets.

@alexandrebl
Created April 14, 2018 21:28
Show Gist options
  • Select an option

  • Save alexandrebl/5f20bdcd43db5172cec478b9b954ba71 to your computer and use it in GitHub Desktop.

Select an option

Save alexandrebl/5f20bdcd43db5172cec478b9b954ba71 to your computer and use it in GitHub Desktop.
Sql Server Get DataBase Size
select
a.FILEID,
[FILE_SIZE_MB] =
convert(decimal(12,2),round(a.size/128.000,2)),
[SPACE_USED_MB] =
convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)),
[FREE_SPACE_MB] =
convert(decimal(12,2),round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2)) ,
NAME = left(a.NAME,15),
FILENAME = left(a.FILENAME,30)
from
dbo.sysfiles a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment