List all computed columns in SQL Server database

Query below lists all computed columns in SQL Server database

Query

select schema_name(o.schema_id) as schema_name,
       object_name(c.object_id) as table_name,
       column_id,
       c.name as column_name,
       type_name(user_type_id) as data_type,
       definition
from sys.computed_columns c
join sys.objects o on o.object_id = c.object_id
order by schema_name,
         table_name,
         column_id;

Columns

  • schema_name - schema name containing table
  • table_name - table name
  • column_id - id of column in table
  • column_name - name of the column
  • data_type - data type of column
  • definition - computing formula

Rows

  • One row represents one column
  • Scope of rows: represents all computed columns from all databases
  • Ordered by schema name, table name and column id

Sample results