Voici une requête donnant toutes les indications de taille des bases de données MS SQL Server :
Dimension des fichiers, dimension du stockage.
-- taille des bases de données
WITH
T1 AS
(
SELECT SUM(CONVERT(BIGINT,CASE WHEN STATUS & 64 = 0 THEN SIZE ELSE 0 END)) AS dbsize,
SUM(CONVERT(BIGINT,CASE WHEN STATUS & 64 0 THEN SIZE ELSE 0 END)) AS logsize
FROM dbo.sysfiles
),
T2 AS
(
SELECT SUM(a.total_pages) AS reservedpages,
SUM(a.used_pages) AS usedpages,
SUM(CASE
WHEN it.internal_type IN (202,204,211,212,213,214,215,216) THEN 0
WHEN a.TYPE 1 THEN a.used_pages
WHEN p.index_id = reservedpages
THEN(dbsize - reservedpages) / 131072.0
ELSE 0
END AS unallocated_space_GO,
reservedpages / 131072.0 AS reserved_G0,
pages / 131072.0 AS data_GO,
(usedpages - pages) / 131072.0 AS index_size_GO,
logsize / 131072.0 AS log_size_GO,
(reservedpages - usedpages) / 131072.0 AS unused_GO
FROM T1 CROSS JOIN T2;
WITH
T1 AS
(
SELECT SUM(CONVERT(BIGINT,CASE WHEN STATUS & 64 = 0 THEN SIZE ELSE 0 END)) AS dbsize,
SUM(CONVERT(BIGINT,CASE WHEN STATUS & 64 0 THEN SIZE ELSE 0 END)) AS logsize
FROM dbo.sysfiles
),
T2 AS
(
SELECT SUM(a.total_pages) AS reservedpages,
SUM(a.used_pages) AS usedpages,
SUM(CASE
WHEN it.internal_type IN (202,204,211,212,213,214,215,216) THEN 0
WHEN a.TYPE 1 THEN a.used_pages
WHEN p.index_id = reservedpages
THEN(dbsize - reservedpages) / 131072.0
ELSE 0
END AS unallocated_space_GO,
reservedpages / 131072.0 AS reserved_G0,
pages / 131072.0 AS data_GO,
(usedpages - pages) / 131072.0 AS index_size_GO,
logsize / 131072.0 AS log_size_GO,
(reservedpages - usedpages) / 131072.0 AS unused_GO
FROM T1 CROSS JOIN T2;
Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES
Expert S.G.B.D relationnelles et langage S.Q.L
Moste Valuable Professionnal Microsoft SQL Server
Société SQLspot : modélisation, conseil, formation,
optimisation, audit, tuning, administration SGBDR
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.
Expert S.G.B.D relationnelles et langage S.Q.L
Moste Valuable Professionnal Microsoft SQL Server
Société SQLspot : modélisation, conseil, formation,
optimisation, audit, tuning, administration SGBDR
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.
L’entreprise SQL Spot
Le site web sur le SQL et les SGBDR
Manquent 2 signes = (sur les ligne « AS logsize » et « WHEN a.TYPE 1″) et 1 parenthèse fermante après le END du CASE
Et j’ai l’impression qu’il en manque un bout à la fin (pas de parenthèse fermante par exemple)