要查询所有表的数据量,可以使用以下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;
这条查询会返回所有表的名称以及每个表的数据量。