Skip to content

Instantly share code, notes, and snippets.

@ryankirkman
Created July 12, 2012 00:11
Show Gist options
  • Save ryankirkman/3094623 to your computer and use it in GitHub Desktop.
Save ryankirkman/3094623 to your computer and use it in GitHub Desktop.
Get the total number of rows in all user tables (Microsoft SQL Server)
-- Sourced from: http://decipherinfosys.wordpress.com/2007/02/13/counting-number-of-records-for-all-the-tables-sql-server/
-- with only slight modifications
SELECT SUM(ind.rows) AS Total_Rows_in_all_user_tables
FROM sysobjects AS obj
INNER JOIN sysindexes AS ind
ON obj.id = ind.id
WHERE obj.xtype = 'u'
AND ind.indid < 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment