By using this query we can get all using database files and their space status
with TblSpace as
(
select
Name,
size * 8.0 / 1024 as TotalSize,
fileproperty(name, 'SpaceUsed') * 8.0 / 1024 as UsedSpace
from sys.database_files
)
select
Name,
TotalSize,
UsedSpace,
convert(decimal(5, 2), UsedSpace / TotalSize * 100) as UsedSpacePer
from TblSpace
with TblSpace as
(
select
Name,
size * 8.0 / 1024 as TotalSize,
fileproperty(name, 'SpaceUsed') * 8.0 / 1024 as UsedSpace
from sys.database_files
)
select
Name,
TotalSize,
UsedSpace,
convert(decimal(5, 2), UsedSpace / TotalSize * 100) as UsedSpacePer
from TblSpace
0 comments:
Post a Comment