我有MS SQL 2008 R2,有500个数据库。查询所有数据库大小的最有效,最简单和“现代”的方法是什么。
输出应包含列:
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) DataFileSizeMB, (select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB from sys.databases db