Get the size of data table in SQL Server

Get the row count and size of data table is very important in SQL Server.
These infomation about data table can select by stored procedure “sp_spaceused”.

usage of “sp_spaceused”: http://msdn.microsoft.com/en-us/library/ms188776.aspx

To get all table’s infomation by the following SQL:

CREATE TABLE #t(name VARCHAR(255), ROWS BIGINT, reserved VARCHAR(20), DATA VARCHAR(20), index_size VARCHAR(20), unused VARCHAR(20))
EXEC sp_MSforeachtable "insert into #t exec sp_spaceused '?'" 
SELECT * FROM #t ORDER BY name
DROP TABLE #t

based: http://www.cnblogs.com/drc/archive/2007/11/29/977189.html

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.