Created
July 26, 2022 21:13
-
-
Save ainsofs/8e223821f5c233bc170f4d6c5d0e0a0d to your computer and use it in GitHub Desktop.
Get table sizes on Ms SQL
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
-- DROP TABLE #tmpTableSizes | |
CREATE TABLE #tmpTableSizes | |
( | |
tableName varchar(100), | |
numberofRows varchar(100), | |
reservedSize varchar(50), | |
dataSize varchar(50), | |
indexSize varchar(50), | |
unusedSize varchar(50) | |
) | |
insert #tmpTableSizes | |
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'" | |
select * from #tmpTableSizes | |
order by cast(LEFT(reservedSize, LEN(reservedSize) - 4) as int) desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment