Table Sizes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Reverse Engineering Meta

Q&A about the site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation

SET NOCOUNT ON;
 
    --dont have permission to update usage
	---DBCC UPDATEUSAGE(0) 

	-- DB size.
	EXEC sp_spaceused

	-- Table row counts and sizes.
	CREATE TABLE #t 
	( 
		[name] NVARCHAR(128),
		[rows] CHAR(11),
		reserved VARCHAR(18), 
		data VARCHAR(18), 
		index_size VARCHAR(18),
		unused VARCHAR(18)
	) 

	INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?''' 

	SELECT *
	FROM   #t
	 

	-- # of rows.
	SELECT SUM(CAST([rows] AS int)) AS [rows]
	FROM   #t
	 
	DROP TABLE #t

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results