Created
July 21, 2016 06:35
-
-
Save jzi96/c48509ef985a30383a86f65890191138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--http://therightstuff.de/2007/11/19/How-To-Obtain-The-Size-Of-All-Tables-In-A-SQL-Server-Database.aspx | |
SET NOCOUNT ON | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment