Created
September 27, 2017 14:59
-
-
Save dannylloyd/0983f62f43e23f06c03ee25d719e7141 to your computer and use it in GitHub Desktop.
Gets row counts for all tables in database
This file contains hidden or 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
CREATE TABLE #counts | |
( | |
table_name varchar(255), | |
row_count int | |
) | |
EXEC sp_MSForEachTable @command1='INSERT #counts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?' | |
SELECT table_name, row_count FROM #counts ORDER BY table_name, row_count DESC | |
DROP TABLE #counts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment