要查詢所有表的數據量,可以使用以下SQL查詢:
SELECT
t.NAME AS TableName,
SUM(p.rows) AS RowCounts
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
WHERE
i.index_id <= 1
GROUP BY
t.NAME
ORDER BY
SUM(p.rows) DESC;
這條查詢會返回所有表的名稱以及每個表的數據量。