Find Tables and Columns in SQL Server System Catalogs

Use SQL Server's catalog views to inspect a database without reading application rows. Including the schema in every result distinguishes tables that share a name, while joining through object IDs keeps the queries accurate.

List User Tables

Connect to the database you want to inspect. The catalogs below describe that database, not every database on the instance.

SQL
SELECT s.name AS SchemaName, t.name AS TableName
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
WHERE t.is_ms_shipped = 0
ORDER BY s.name, t.name;

Each row identifies a visible user table. An empty result can mean the database has no visible tables or your account lacks metadata visibility. It does not establish that the entire server is empty.

Inspect Column Definitions

SQL
SELECT s.name AS SchemaName, t.name AS TableName,
       c.column_id AS ColumnId, c.name AS ColumnName,
       ty.name AS TypeName, c.max_length AS MaxLengthBytes,
       c.precision, c.scale, c.is_nullable, c.is_identity,
       c.is_computed
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
JOIN sys.columns AS c ON c.object_id = t.object_id
JOIN sys.types AS ty ON ty.user_type_id = c.user_type_id
WHERE t.is_ms_shipped = 0
ORDER BY s.name, t.name, c.column_id;

Expect one row per column, ordered by the table's column IDs. max_length is measured in bytes, and -1 denotes a max-length type. It is not a universal character count, particularly for Unicode data. Column IDs may contain gaps after schema changes.

Count Columns per Table

SQL
SELECT s.name AS SchemaName, t.name AS TableName,
       COUNT(c.column_id) AS ColumnCount
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
LEFT JOIN sys.columns AS c ON c.object_id = t.object_id
WHERE t.is_ms_shipped = 0
GROUP BY s.name, t.name
ORDER BY s.name, t.name;

This counts catalog columns, including computed and hidden columns. If you want only user-facing columns, apply a deliberate rule such as excluding c.is_hidden = 1. Do not substitute MAX(column_id) for a count.

Find a Specific Column

SQL
DECLARE @ColumnName sysname = N'CreatedAt';

SELECT s.name AS SchemaName, t.name AS TableName,
       c.name AS ColumnName
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
JOIN sys.columns AS c ON c.object_id = t.object_id
WHERE t.is_ms_shipped = 0
  AND c.name = @ColumnName
ORDER BY s.name, t.name;

Use LIKE N'%Created%' instead of equality when you intentionally want a pattern search. Matching follows the relevant collation's case rules. These queries replace older sysobjects/syscolumns compatibility-view recipes and avoid returning unrelated system objects or ambiguous table names.

Microsoft References

Author: Herman Schoenfeld