www.diy567.com累了,去上面休息一下下,QQ空间,美文,非主流,网络日记,搞笑短信,祝福短信,热门短信,有意思啊
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