Finding a common column in all tables in a DB

  • I have a need to find out which tables in a DB contain a column name, say department.  Does anyone know of a T-SQL query I can write to do this?  Thanks.

  • Select * from INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'Departement'

  • Thanks so much, one of our vendors is changing a column, which appears in many tables.  Guess what?  They forgot to do it in 2 tables!!.  Charger.  (By the way this will be a very valuable query in the future).  Thanks again.

  • I like to use this so I only get the User tables.

    SELECT obj.name

      FROM syscolumns           col

            , sysobjects            obj

     WHERE col.id      = obj.id

       AND col.name   = 'Department'

       AND obj.xtype   = 'U'

     

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

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