SELECT
t.NAME AS 表名,
p.rows AS 行数,
SUM(a.total_pages) * 8 / 1024 AS 总空间MB,
SUM(a.used_pages) * 8 / 1024 AS 已用空间MB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 / 1024 AS 未用空间MB
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
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.NAME, p.Rows
ORDER BY
总空间MB DESC;
**
收缩数据库日志文件 第一步,设置数据库恢复简单模式 第二步,开启自动收缩
**
第三步开始手动收缩
**
结束。 200G的文件,直接缩完了。
**