Skip to content

Instantly share code, notes, and snippets.

@saurabhj
Last active November 23, 2016 09:38
Show Gist options
  • Save saurabhj/be26b612f4d95981ab0bd44e15858b76 to your computer and use it in GitHub Desktop.
Save saurabhj/be26b612f4d95981ab0bd44e15858b76 to your computer and use it in GitHub Desktop.
Tables and their Rows in MS-SQL
-- Returns a list of all User created tables on MS-SQL along with a count of rows of each
SELECT o.NAME,
i.rowcnt
FROM sysindexes AS i
INNER JOIN sysobjects AS o ON i.id = o.id
WHERE i.indid < 2 AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0
ORDER BY o.NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment