0

I'm looking to search for a specific column name across an entire SQL DB, and it's unclear how to go about doing that.

Would anyone have advice on the correct syntax?

RalphBiggerton
  • 179
  • 5
  • 19

1 Answers1

2

You can query the sys.columns system table and join various other system tables. Something along the lines of:

SELECT o.type,
       s.name schema_name,
       o.name object_name,
       c.name column_name
       FROM sys.columns c
            INNER JOIN sys.objects o
                       ON o.object_id = c.object_id
            INNER JOIN sys.schemas s
                       ON s.schema_id = o.schema_id
       WHERE c.name = <column name you search for>;
sticky bit
  • 36,626
  • 12
  • 31
  • 42