Microsoft SQL Server Retrieve information about the database Count the Number of Tables in a Database

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

This query will return the number of tables in the specified database.

USE YourDatabaseName
SELECT COUNT(*) from INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' 

Following is another way this can be done for all user tables with SQL Server 2008+. The reference is here.

SELECT COUNT(*) FROM sys.tables


Got any Microsoft SQL Server Question?