Get the Record Count for all the Tables in a Database in SQL Server
WHERE TABLE_TYPE = ‘BASE TABLE’
ORDER BY TABLE_SCHEMA, TABLE_NAMEEXEC Sp_executesql @QueryString
When you run the above query in AdventureWorksDW database then the results will be as shown below (Tables/Counts might slightly vary depending on the version of AdventureWorksDW).
Posted on February 19, 2010, in Code Snippets, Interview Questions, SQL Server, T-SQL, T-SQL Questions, T-SQL Snippets, T-SQL Tips, Tips 'N' Tricks and tagged Code Snippets, MSBI, SQL Server, T-SQL, Tips and Tricks. Bookmark the permalink. 3 Comments.