I need to find all the tables in a database that are empty (have nothing in
them). I know how to do it individually but can I do a mass search for
tables without data.
Thanks,EXEC sp_msforeachtable 'IF NOT EXISTS (SELECT * FROM ?) PRINT ''?'''
This proc is undocumented so don't use it in production code.
David Portas
SQL Server MVP
--|||If your statistics are up2date, you could also do this:
select object_name(id)
from sysindexes
where rowcnt<=0
and indid in (0,1)
and objectproperty(id,'isUserTable')=1
-oj
"Richard Thayne" <richard.thayne@.data2logistics.com> wrote in message
news:%23Knwk1UFFHA.3972@.TK2MSFTNGP15.phx.gbl...
>I need to find all the tables in a database that are empty (have nothing in
>them). I know how to do it individually but can I do a mass search for
>tables without data.
> Thanks,
>
No comments:
Post a Comment