I am converting an application and working to load its data into my own sql database and tables. the old app database had some 425+ tables, of which, "only" 118 or so are actually used. I'd like to reduce the clutter and drop all tables that have zero rows. I know with a join of sysindexes and sysobjects, I can get a list of all tables with zero rows.
select CONVERT(VARCHAR(25),a.name) name, b.rows
from sysobjects a, sysindexes b
where a.id = b.id
and b.indid < 2
group by a.name, b.rows
order by b.rows desc
Can I embed this query into a DROP TABLE script to do a mass drop?