¿Queremos evitar estar viendo los files de cada base de datos para conocer su tamaño?, les dejo una consulta en SQL Server que les dará el tamaño del archivo mdf y ldf, de cada base de datos de su instancia, ejecútenla sobre la BD Master:
with fs
as
(
select database_id, type, size * 8.0 / 1024 size from sys.master_files
)
select name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogSizeMB,
((select sum(size) from fs where type = 0 and fs.database_id = db.database_id)+ (select sum(size) from fs where type = 1 and fs.database_id = db.database_id))
TotalDatabaseSizeMB
from sys.databases db
order by TotalDatabaseSizeMB DESC
as
(
select database_id, type, size * 8.0 / 1024 size from sys.master_files
)
select name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogSizeMB,
((select sum(size) from fs where type = 0 and fs.database_id = db.database_id)+ (select sum(size) from fs where type = 1 and fs.database_id = db.database_id))
TotalDatabaseSizeMB
from sys.databases db
order by TotalDatabaseSizeMB DESC
¡Saludos!.
No hay comentarios:
Publicar un comentario