declare @sql varchar(200)
declare @tn nvarchar(20)
declare @table table(tn nvarchar(30),sql nvarchar(100))
insert into @table select table_name,'insert into ##temp select '''+table_name+''', count(*) from '+table_name from INFORMATION_SCHEMA.TABLES where table_type='BASE TABLE'
--delete ##temp
--select * from @table
create table ##temp(tn nvarchar(30),c int)
Declare C_CLY CURSOR for
select tn,sql from @table
open C_CLY
fetch next from C_CLY
into @tn,@sql
while @@FETCH_STATUS=0
begin
print @sql
exec(@sql)
fetch next from C_CLY
into @tn,@sql
end
close C_CLY
DEALLOCATE C_CLY
select * from ##temp where c>0
--select * from INFORMATION_SCHEMA.TABLES where table_type='BASE TABLE'