Información física sobre BBDD (uso, espacio, etc)

in sql •  6 years ago 

Este script además de ser útil para mí, está escrito también para otros para que puedan hacer exactamente lo que yo hice, modificarlo y terminar con un script que se ajuste a sus necesidades.

select
d.name,
f.name as filetype,
f.physical_name as physicalfile,
f.state_desc as onlinestatus,
f.size * 8.00 * 1024.00 as bytes,
cast((f.size * 8.00 * 1024.00) / 1048576.00 as numeric (18,2)) as megabytes,
cast((f.size * 8.00 * 1024.00) / 1073741824.00 as numeric(18,2)) as gigabytes,
cast(cast(v.total_bytes - v.available_bytes as float) / cast(v.total_bytes as float) * 100 as numeric(18,2)) used_disk_percent
from
sys.master_files f
inner join sys.databases d on d.database_id = f.database_id
cross apply sys.dm_os_volume_stats(f.database_id, f.file_id) v
order by
d.name

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!