??MSSQL????????????????????小
???????????? ???????[ 2013/5/6 10:43:17 ] ????????
??????????????????????????????????????????????????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 ##'
??????
???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11