select 'Customers' as tablename
, count(*) as row_count
from Customers
union all
select 'Orders' as tablename
, count(*) as row_count
from Orders
union all
select 'Products' as tablename
, count(*) as row_count
from Products
union all
...
If you need to run this for all tables in your database, you can generate
the list of tables from the INFORMATION_SCHEMA.TABLES view:
select table_name
from information_schema.tables
where table_schema = 'mydatabase'
Then you can use the result set of this query along with a text editor
to generate the first query.
Search and Browse the Expert Answer Center Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.