Hi,
here is a sample script. As segments belong to databases, you have to be in the database in question:
select distinct "databasename" = db_name(uu.dbid), "devicename" = d.name, "segmentname" = seg.name,
"size [MB]" = (d.high - d.low+1) /512
from master..sysdevices d, master..sysusages uu, syssegments seg
where d.status & 16 = 0
and uu.vdevno = d.vdevno
and db_name(uu.dbid) = db_name()
and power(2, segment) & uu.segmap > 0
order by uu.dbid, d.name
The output will look like this:
databasename devicename segmentname size [MB]
------------- ---------------- ------------- -----------
tools tools_data_001 default 2048
tools tools_data_001 myseg 2048
tools tools_data_001 system 2048
tools tools_log_001 logsegment 1024
Please note, that a device appears once for each segment located on it. So in the example the tools_data_001 device is listed three times as three segments (default, myseg, and system) are placed on the device. The log device contains one segment only and therefore it appears only once.
Best regards,
Juergen