create table #temp(name varchar(50),count int)
declare @tablename varchar(50),@sql varchar(500)
declare gettablenum_cur cursor for select name from sysobjects where xtype='u'
open gettablenum_cur
fetch gettablenum_cur into @tablename
while @@fetch_status=0
begin
select @sql='insert #temp(name,count) '+'select '+''''+@tablename+''''+','+'count(1) from '+@tablename
exec(@sql)
fetch gettablenum_cur into @tablename
end
select * from #temp order by name
close gettablenum_cur
deallocate gettablenum_cur
drop table #temp
最后修改:2017 年 01 月 22 日
© 允许规范转载
相关文章
- 无相关文章