Home > SQL SERVER > How To Obtain The Size Of All Tables In A SQL Server Database

How To Obtain The Size Of All Tables In A SQL Server Database


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

Advertisements
Categories: SQL SERVER
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: