IT Knowledge Support Centre

SQL server: table count and size

 
Monday, May 24, 2010, 09:15 AM
Posted by Administrator
The most common method used for this is shows below.
SELECT COUNT(*) FROM tablename

The same can be acheived by using the builtin SP

EXEC sp_spaceused 'tablename'

To get revords counts and its size of all the tables then use following(#Ballpark: because the sysindex table is not updated constantly.)

SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY
2 DESC


add comment ( 4 views )   |  permalink   |   ( 3.1 / 204 )

<Back | 1 | Next> Last>>