--☆★☆★显示当前数据库每个表的记录数
create table Allwin(
TableName nvarchar(100)
,RowCounts integer
)
declare @RE table(
TableName nvarchar(100)
)
insert into @RE(TableName)
select name
from sysobjects o
where o.xtype='U' and o.name<>'dtproperties'
order by name
declare @TableName nvarchar(100)
declare @SQL nvarchar(200)
declare CR cursor for select TableName from @RE
open CR
fetch next from CR into @TableName
while(@@fetch_status=0)
begin
set @SQL='insert into Allwin(TableName,RowCounts)'
set @SQL=@SQL+' select '''+@TableName+''',count(*) from '+@TableName
exec (@SQL)
fetch next from CR into @TableName
end
close CR
deallocate CR
select * from Allwin order by RowCounts desc
drop table Allwin
|