Determine SQL Server Database Size

后端 未结 8 1571
野性不改
野性不改 2020-12-07 22:34

SQL Server 2005/2008 Express edition has the limitation of 4 GB per database. As far as I known the database engine considers data only, thus excluding log files, unused spa

8条回答
  •  囚心锁ツ
    2020-12-07 22:49

    I always liked going after it directly:

    SELECT 
        DB_NAME( dbid ) AS DatabaseName, 
        CAST( ( SUM( size ) * 8 ) / ( 1024.0 * 1024.0 ) AS decimal( 10, 2 ) ) AS DbSizeGb 
    FROM 
        sys.sysaltfiles 
    GROUP BY 
        DB_NAME( dbid )
    

提交回复
热议问题