Find number of tables in database

Query below returns total number of tables in current database.

Query

select count(*) as tables
from MSysObjects
where
   MSysObjects.type In (1,4,6)
   and MSysObjects.name not like '~*'   
   and MSysObjects.name not like 'MSys*'

Notes

Note that we have excluded system tables (names starting with ~ or Msys).

Columns

  • tables - number of tables in a database

Rows

Query returns just one row.

Sample results

Those results show that there are 229 tables in the database.

sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.