Hier ist eine Abfrage, die Sie die Gesamtgröße von Tabelle gibt, die Anzahl der Zeilen und Bytes pro Zeile:
select
o.name,
max(s.row_count) AS 'Rows',
sum(s.reserved_page_count) * 8.0/(1024 * 1024) as 'GB',
(8 * 1024 * sum(s.reserved_page_count))/(max(s.row_count)) as 'Bytes/Row'
from sys.dm_db_partition_stats s, sys.objects o
where o.object_id = s.object_id
group by o.name
having max(s.row_count) > 0
order by GB desc
Und hier ist eine Abfrage, die die gleiche wie oben ist, aber es bricht durch den Index nach unten:
select
o.Name,
i.Name,
max(s.row_count) AS 'Rows',
sum(s.reserved_page_count) * 8.0/(1024 * 1024) as 'GB',
(8 * 1024* sum(s.reserved_page_count))/max(s.row_count) as 'Bytes/Row'
from
sys.dm_db_partition_stats s,
sys.indexes i,
sys.objects o
where
s.object_id = i.object_id
and s.index_id = i.index_id
and s.index_id >0
and i.object_id = o.object_id
group by i.Name, o.Name
having SUM(s.row_count) > 0
order by GB desc
Dies ergibt eine deutlich geringere Größe als sp_spaceUsed auf SQL Server (z. nur 40% oder so). Gibt es einen Grund dafür? Wenn Sie eine ODBC-Verbindung verwenden, wie können Sie feststellen, dass es Azure am Back-End ist? –
Troy - Das hat super funktioniert !! Vielen Dank! – Rogala