Skip to content

Instantly share code, notes, and snippets.

@brentmaxwell
Created March 17, 2015 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentmaxwell/4c71de0eeb499b85e389 to your computer and use it in GitHub Desktop.
Save brentmaxwell/4c71de0eeb499b85e389 to your computer and use it in GitHub Desktop.
Get *approximate* row counts of all tables in a db
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.ROWS)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U' AND
si.id = OBJECT_ID(so.name)
GROUP BY so.name ORDER BY so.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment