SELECT 'ALL' AS DatabaseName
, SUM ( UsedSpace_GB ) AS DatabaseName
, SUM ( AllocatedSpace_GB ) AS UsedSpace_GB
, current_timestamp as CurrentTime
FROM (
SELECT ORX.database::nvarchar(64) AS DatabaseName ,
case when sum(SOD.used_bytes) is null then 0 else SUM(SOD.used_bytes)/1073741824 end AS UsedSpace_GB,
case when sum(SOD.allocated_bytes) is null then 0 else SUM(SOD.allocated_bytes)/1073741824 end AS AllocatedSpace_GB,
current_timestamp as CurrentTime
FROM _V_SYS_OBJECT_DSLICE_INFO SOD INNER JOIN _V_OBJ_RELATION_XDB ORX ON ORX.objid = SOD.tblid
GROUP BY CurrentTime, DatabaseName
) AS ALL_DB_SIZES
UNION ALL
SELECT ORX.database::nvarchar(64) AS DatabaseName ,
case when sum(SOD.used_bytes) is null then 0 else SUM(SOD.used_bytes)/1073741824 end AS UsedSpace_GB,
case when sum(SOD.allocated_bytes) is null then 0 else SUM(SOD.allocated_bytes)/1073741824 end AS AllocatedSpace_GB,
current_timestamp as CurrentTime
FROM _V_SYS_OBJECT_DSLICE_INFO SOD INNER JOIN _V_OBJ_RELATION_XDB ORX ON ORX.objid = SOD.tblid
GROUP BY CurrentTime, DatabaseName
ORDER BY UsedSpace_GB DESC
;
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!