query to find a column in a sql server with several databases

  • How do I find a column in a sql server which had several databases with several tables in each database ? I am looking for a sql query . I do not want to open in design view for each table

    Thanks

  • If you need to find out which table in a database has a certain column, you can use something like this:

    select

    (select name

    from sys.tables

    where object_id = columns.object_id), *

    from sys.columns

    where name = 'MyColumnName';

    Does that help?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • select table_name,column_name from information_schema.columns

    where column_name='ColumnNameHere'

    MJ

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

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