notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Métadonnées bases et fichiers.sql
2020-11-26 18:38:25 +01:00

31 lines
910 B
SQL

-- métadonnées des bases et fichiers de toute sles bases
SELECT *
FROM sys.databases;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
type_desc,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files
GROUP BY type_desc
ORDER BY type_desc;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
db.name,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files AS mf
JOIN sys.databases AS db
ON mf.database_id = db.database_id
GROUP BY db.name
ORDER BY SIZE_GB DESC;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
db.name, type_desc,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files AS mf
JOIN sys.databases AS db
ON mf.database_id = db.database_id
GROUP BY db.name, type_desc
ORDER BY type_desc, SIZE_GB DESC;