SQL Server 一般都是跟磁盘空间可用率挂钩 数据文件也都是自增长 所以不用管;
如下SQL语句可以查询SQL Server数据库当前登录用户数据的表空间,但是没什么意义 因为SQL Server是72M自增长,只能看出当前块的自增长离下次自增长还有多少空间:
SELECT
DB_NAME(database_id) AS DatabaseName,
CAST(ROUND(SUM(size) * 8 / 1024.0, 2) AS NUMERIC(36, 2)) AS TotalSizeMB,
CAST(ROUND(SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)) * 8 / 1024.0, 2) AS NUMERIC(36, 2)) AS UsedSizeMB,
CAST(ROUND((SUM(size) - SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT))) * 8 / 1024.0, 2) AS NUMERIC(36, 2)) AS FreeSizeMB
FROM
sys.master_files
WHERE
type_desc = 'ROWS'
GROUP BY
database_id;
标签:SUM,数据库,Server,CAST,1024.0,SQL,ROUND From: https://www.cnblogs.com/long2050/p/18648444