declare @tablename varchar(100)
declare @sql nvarchar(4000)
declare @Num int
declare tb_cursor scroll cursor for select name from sysobjects where xtype='U'
open tb_cursor
fetch next from tb_cursor into @tablename
while @@fetch_status=0
begin
set @sql=N'select @Num=count(1) from '+@tablename
exec sp_executesql @sql,N'@Num int out',@Num out
if @Num>0 print @tablename
fetch next from tb_cursor into @tablename
end
close tb_cursor
deallocate tb_cursor
declare @sql nvarchar(4000)
declare @Num int
declare tb_cursor scroll cursor for select name from sysobjects where xtype='U'
open tb_cursor
fetch next from tb_cursor into @tablename
while @@fetch_status=0
begin
set @sql=N'select @Num=count(1) from '+@tablename
exec sp_executesql @sql,N'@Num int out',@Num out
if @Num>0 print @tablename
fetch next from tb_cursor into @tablename
end
close tb_cursor
deallocate tb_cursor