| How to
count the rows in all tables? |
|
Execute the following
script in Query Editor to generate a script for counting rows
in all the schemas and tables of the database:
use AdventureWorks;
select 'select '''+s.name+'.'+o.name+''', count(*)
from '
+s.name+'.'+o.name
from sys.objects o
join sys.schemas s
on o.schema_id=s.schema_id
where type = 'U'
order by s.name, o.name
|
| The World Leader
in SQL Server Training |
|