SQL查询所有用户表记录数

来源:互联网 发布:白塔软件 编辑:程序博客网 时间:2024/05/18 01:44

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

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/htl258/archive/2009/06/11/4259546.aspx

原创粉丝点击