📜  sql server 查询数据库可用空间 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:54.605000             🧑  作者: Mango

代码示例1
SELECT DB_NAME() AS DbName, 
    name AS FileName, 
    type_desc,
    size/128.0 AS CurrentSizeMB,  
    size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files
WHERE type IN (0,1);