USE master GO IF OBJECT_ID('sp_ABTableSize') IS NOT NULL DROP PROCEDURE sp_ABTableSize GO CREATE PROCEDURE sp_ABTableSize (@ObjectName varchar(30) = '') /* Name: sp_ABTableSize Author: Vince Iacoboni vince.iacoboni@btalexbrown.com Purpose: Quick listing of rows, data size, index size, reserved space for all tables or a given table name pattern 06/01/97 VRI Created. 04/20/98 VRI Corrected reserved calculation to exclude reserved column from nonclustered indexes. Also, changed the index size to the same calculation used in sp_spaceused. Use input parameter as mask. Thanks, Jim Craddock. */ AS IF charindex(@ObjectName, '%') = 0 SELECT @ObjectName = rtrim(@ObjectName) + '%' SELECT user_name(uid) + '.' + o.name TableName, i.rows Rows, i.dpages*2 + isnull(itext.used*2, 0) DataSizeInK, (i.used - i.dpages)*2 IndexSizeInK, i.reserved*2 + isnull(itext.reserved*2, 0) ReservedSizeInK FROM sysobjects AS o INNER JOIN sysindexes AS i ON o.id = i.id AND i.indid < 2 LEFT OUTER JOIN sysindexes AS itext ON o.id = itext.id AND itext.indid = 255 WHERE o.type = 'U' AND o.name like @ObjectName ORDER BY ReservedSizeInK desc GO GRANT EXECUTE ON dbo.sp_ABTableSize TO public GO