SQL 查询各表所占大小

SELECT  OBJECT_NAME(id) tablename ,
        CASE WHEN reserved * 8 > 1024 THEN RTRIM(8 * reserved / 1024) + MB
             ELSE RTRIM(reserved * 8) + KB
        END DataReserve ,
        CASE WHEN dpages * 8 > 1024 THEN RTRIM(8 * dpages / 1024) + MB
             ELSE RTRIM(dpages * 8) + KB
        END Used ,
        CASE WHEN 8 * ( reserved - dpages ) > 1024
             THEN RTRIM(8 * ( reserved - dpages ) / 1024) + MB
             ELSE RTRIM(8 * ( reserved - dpages )) + KB
        END unused ,
        CASE WHEN ( 8 * dpages / 1024 - rows / 1024 * minlen / 1024 ) > 1024
             THEN RTRIM(( 8 * dpages / 1024 - rows / 1024 * minlen / 1024 )
                        / 1024) + MB
             ELSE RTRIM(( 8 * dpages / 1024 - rows / 1024 * minlen / 1024 ))
                  + KB
        END FREE ,
        rows AS Rows_Count
FROM    sys.sysindexes
WHERE   indid = 1
        AND status = 2066 -- status=‘18‘
ORDER BY reserved DESC

 

SQL 查询各表所占大小

上一篇:轻型Web框架——Nancy


下一篇:System.net.mail.smtpException;服务器提交了协议冲突 服务器响应为: