use 数据库名
if object_id('tempdb..##') is not null drop table ##
select cast(null as sysname) as 表名称, 1 as 记录数 into ## where 1 = 0
declare @TableName sysname
declare testcur cursor for select [name] from sysobjects where xtype ='U' order by [name]
open testcur
fetch next from testcur into @TableName
while @@fetch_status = 0
begin
exec('insert into ## select ''' + @TableName + ''', (select count(1) from ' + @TableName + ')')
fetch next from testcur into @TableName
end
close testcur
deallocate testcur
select * from ##
where 记录数>4000*10000