Wednesday, March 7, 2012

quick count of all tables in a database

How can I get a quick count of all tables in a database? Is there a way to do this? Can the table count exclude system tables?

What about this:

SELECT COUNT(*) FROM sys.tables WHERE is_ms_shipped=0

One problem is that "sysdiagrams" is not marked as is_ms_shipped=1. If you don't want to include it, add name <>'sysdiagrams' condition.

|||SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE LIKE 'BASE%'

No comments:

Post a Comment