Skip to content

Instantly share code, notes, and snippets.

@MauroGarcia
MauroGarcia / SearchColumnInTables.sql
Last active October 2, 2020 21:15
Get all tables in database that have a specific column
SELECT
      T.name AS TableName,
      C.name AS ColumnName
FROM
      sys.sysobjects    AS T (NOLOCK)
INNER JOIN sys.all_columns AS C (NOLOCK) ON T.id = C. object_id AND T.XTYPE = 'U'
WHERE
      C.NAME LIKE '%Column%' -- Change here
ORDER BY
      T.name ASC