??????????????????????????????????????????????????SQL??????£?

View Code

SELECT  OBJECT_NAME(id) tablename ??
 * reserved / 1024 reserved ??
        RTRIM(8 * dpages / 1024) + 'Mb' used ??
 * ( reserved - dpages ) / 1024 unused ??
 * dpages / 1024 - rows / 1024 * minlen / 1024 free ??
        rows
FROM    sysindexes
WHERE   indid = 1
ORDER BY reserved DESC

???????н???????

??????????????Щ??????????????????????????????????????SQL??????£?

View Code

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

???????н?????£?

?????в?????????????????

????????zjeagle??????????????????????????棺

exec sp_MSForEachTable
@precommand=N' create table ##(id int identity?????? sysname??????? int??????? int???????? Nvarchar(10)??????? varchar(10)??????????? varchar(10)??δ???? varchar(10))'??
@command1=N'insert ##(?????????????????????????????????δ????) exec sp_spaceused ''?'' update ## set ?????=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()'??
@postcommand=N'
select * from ## order by convert(INT??replace(??????"KB"??"")) desc drop table ##'