I have 2-3 different column names that I want to look up in the entire database and list out all tables which have those columns. Is there any easy script?
To get all tables with columns columnA or ColumnB in the database YourDatabase:
columnA
ColumnB
YourDatabase
SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('columnA','ColumnB') AND TABLE_SCHEMA='YourDatabase';
1.4m articles
1.4m replys
5 comments
57.0k users