Is there an SQL Query to return all tables which contain a specific column.

  • Is there a query which can return all tables that contain a specific column name. Below is what i have to return all the tables. Im suspecting there is a 'where statement' to look through all the column_names within these tables and just get the tables that contain a specific column name.

    Select TABLE_NAME as

    from information_schema.tables order by

    .

    Thanks in advance....

  • You could try something like this:

    Select tables.TABLE_NAME, cols.column_name from information_schema.tables tables

    inner join information_schema.columns cols on tables.table_name=cols.table_name

    where cols.column_name='MyColumnName'

    order by tables.TABLE_NAME;

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Hey, that worked well. Thank you very much for your time.....

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply