if object_id('tb') is not null drop table tb
go
create table tb(name varchar(50),cnt int)
go
set nocount on
declare c cursor for
select name from sysobjects where type='u' order by name
open c
declare @tb varchar(255)
fetch next from c into @tb
while @@fetch_status=0
begin
exec('insert tb select '''+@tb+''' name,count(*) cnt from ['+@tb+'] having count(*)<>0')
fetch next from c into @tb
end
close c
deallocate c
set nocount off
select * from tb
SQL查询所有用户表记录数
最新推荐文章于 2024-08-12 15:50:01 发布