Categories
Posts

Get the row count from each table in a database

Just an SQL Snippet for today: create table #rowcount (tablename varchar(128), rowcnt int) exec sp_MSforeachtable ‘insert into #rowcount select ”?”, count(*) from ?’ select * from #rowcount order by rowcnt desc drop table #rowcount

Just an SQL Snippet for today:

createtable #rowcount (tablename varchar(128),rowcnt int)exec sp_MSforeachtable insertinto #rowcount select ?,count(*) from ? select * from#rowcount order by rowcnt desc drop table #rowcount