SQL Server Tricks

  1. sp_msForEachTable 对每个表进行操作

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

原文地址:https://www.cnblogs.com/mrfangzheng/p/1176331.html