Neera Saxena Neera Saxena -4 years ago 82
SQL Question

query to fetch the all table name where there is a certain column name

How to fetch all tables that have for example a column called

CreatedBy
in SQL Server 2008.

Answer Source

In Sql Server you can get this by looking at the sys.columns table

  use DB_MAST_AERRE
  select 
         OBJECT_SCHEMA_NAME(object_id) AS SchemaName,
         object_name(object_id) AS TableName
         from 
            sys.columns
            where name = 'CreatedBy'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download