Querying system table for space usage information

You may want to write some of your own queries for additional information about physical storage. For example, to determine the total number of 2K blocks of storage space that exist on Adaptive Server, you can query sysdevices:

select sum(convert(numeric(20,0), high - low + 1))
from sysdevices 
where status & 2 = 2
----------------- 
             230224

In this example, the 2 in the status column indicates a physical device. high is the highest valid 2k block on the device, so you must add 1 to get the true count from the subtraction and convert counts to numeric(20,0) to avoid overflow from integer addition in the sum.