Friday, March 11, 2011

Count of each table in database

the query below will generate sql statements to count number of rows in each table on the database.

SELECT 'select '''+ name + ''', count(*) from [' + name + '] union'
FROM Sysobjects
WHERE Type='U'
ORDER BY 1;