简体   繁体   中英

How to get TOP larger tables in SQL Server 2000 and their sizes

有没有办法通过 T-SQL 在 SQL Server 2000 引擎中获取更大的表及其各自的大小?

I think this script works with SQL Server 2000 even if sp_msforeachtable was not documented

CREATE TABLE #SpaceUsed (
 TableName sysname
,NumRows BIGINT
,ReservedSpace VARCHAR(50)
,DataSpace VARCHAR(50)
,IndexSize VARCHAR(50)
,UnusedSpace VARCHAR(50)
)
DECLARE @str VARCHAR(500)
SET @str =  'exec sp_spaceused ''?'''
INSERT INTO #SpaceUsed
EXEC sp_msforeachtable @command1=@str

SELECT * FROM #SpaceUsed ORDER BY ReservedSpace DESC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM