Get all table names with a given column name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sashi

    Get all table names with a given column name

    All, is there a way of getting all table names that contain a column
    name?
    I'm looking at a DB that has 125+ tables and I'm interested in finding
    all table names that contain the column order_date.
    How can I do it?
    TIA,
    Sashi

  • Madhivanan

    #2
    Re: Get all table names with a given column name


    Select table_name from information_Sch ema.columns where
    column_name='co lumn name'

    Madhivanan


    Sashi wrote:
    All, is there a way of getting all table names that contain a column
    name?
    I'm looking at a DB that has 125+ tables and I'm interested in finding
    all table names that contain the column order_date.
    How can I do it?
    TIA,
    Sashi

    Comment

    • Dan Guzman

      #3
      Re: Get all table names with a given column name

      How can I do it?

      One method is to query the INFORMATION_SCH EMA views:

      SELECT
      c.TABLE_SCHEMA,
      c.TABLE_NAME
      FROM INFORMATION_SCH EMA.TABLES t
      JOIN INFORMATION_SCH EMA.COLUMNS c ON
      t.TABLE_SCHEMA = c.TABLE_SCHEMA AND
      t.TABLE_NAME = c.TABLE_NAME
      WHERE
      t.TABLE_TYPE = 'BASE TABLE' AND
      c.COLUMN_NAME = 'column order_date'
      ORDER BY
      c.TABLE_SCHEMA,
      c.TABLE_NAME

      --
      Hope this helps.

      Dan Guzman
      SQL Server MVP

      "Sashi" <smalladi@gmail .comwrote in message
      news:1152627046 .364476.199010@ h48g2000cwc.goo glegroups.com.. .
      All, is there a way of getting all table names that contain a column
      name?
      I'm looking at a DB that has 125+ tables and I'm interested in finding
      all table names that contain the column order_date.
      How can I do it?
      TIA,
      Sashi
      >

      Comment

      Working...