Find a specific column in an unknown table in a database?

I am trying to find a specific column that is unknown in a database with 125 tables. I am looking for a wildcard, say, "% watcher%". Is it possible?

+3
source share
2 answers
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name LIKE '%watcher%' [AND table_schema = 'database'] 
+4
source

This shows you a bit more information ...

 DECLARE @columnName as varchar(100) SET @columnName = 'ColumnName' SELECT t.name AS Table, c.name AS Column, ty.name AS Type, c.max_length AS Length, c.precision AS Precision FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID INNER JOIN sys.types ty ON c.system_type_id = ty.system_type_id WHERE c.name LIKE @columnName ORDER BY t.name, c.name 

Hope this helps!

+1
source

All Articles