1. Query to check the database space
SELECT DatabaseName ,
SUM (MaxPerm) as Allocated_Space,
SUM (CurrentPerm) as Occupied_Till_Now,
((SUM (CurrentPerm))/NULLIFZERO (SUM(MaxPerm)) * 100 (FORMAT '9.99%',
TITLE 'Percent // Used'))
FROM DBC.DiskSpace where DatabaseName in ('dbname1','dbname2') GROUP BY 1 ORDER BY 4 desc;