Skip to content

Instantly share code, notes, and snippets.

@tompazourek
Created October 24, 2017 13:12
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 tompazourek/e1ca147cfc884a9f220e2c0fe2e81cb7 to your computer and use it in GitHub Desktop.
Save tompazourek/e1ca147cfc884a9f220e2c0fe2e81cb7 to your computer and use it in GitHub Desktop.
Database tables and rows
SELECT
CONVERT(NVARCHAR(MAX), t.[table_schema]) AS [Owner],
CONVERT(NVARCHAR(MAX), t.[table_name]) AS [TableName],
MAX(i.[rows]) AS [RecordCount]
FROM
[sysindexes] i,
[information_schema].[tables] t
WHERE
t.[table_name] = OBJECT_NAME(i.[id])
AND t.[table_type] = 'BASE TABLE'
GROUP BY
t.[table_schema],
t.[table_name]
ORDER BY
t.[table_schema],
t.[table_name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment