Wednesday, September 19, 2012

Get Number of tables in a database in SQL Server

Here is the query to find total number of tables in a specific database in SQL Server.


SELECT COUNT(*) FROM information_schema.tables WHERE table_type = 'BASE TABLE'


SELECT COUNT(*) FROM sysobjects WHERE xtype = 'U'

DBName is the name of your database in which you want to find the total number of tables.