Returns names and metadata for every table in the current SQL Server database.
Query the catalog view sys.tables
. It is lightweight, indexed, and always up-to-date, making it the go-to option for developers and scripts.
Join sys.tables
with sys.schemas
or filter on INFORMATION_SCHEMA.TABLES
. This adds the schema name to every table, avoiding naming collisions.
INFORMATION_SCHEMA.TABLES
is ANSI-standard, so code ports easily to other RDBMS. However, it omits SQL Server–specific metadata.
Apply a WHERE
clause with LIKE
against t.name
or TABLE_NAME
. Use wildcards (e.g., 'Orders%'
) to narrow large catalogs quickly.
Join sys.dm_db_partition_stats
to sys.tables
and aggregate row_count
. This delivers live counts without running separate queries.
Select only columns you need, limit to user schemas (schema_id >= 4
), and add conditions to avoid scanning unnecessary system objects.
No. It returns only base tables. Use sys.views or INFORMATION_SCHEMA.VIEWS for view metadata.
Yes. Azure SQL supports sys.tables and INFORMATION_SCHEMA, so the syntax remains identical.