Have you ever just been given a column name and not known which table it was in? Needed to check whether a column existed within a database?…
Well today I was just given a column name and told the information I needed was in there but alas they didn’t know which table it was in.
I could have gone through each table but that is very inefficient and I can more effectively harness the power of SQL to get the answer quickly and easily.
I knew that the INFORMATION_SCHEMA.COLUMNS would be a great place to start and did the below query.
FROM INFORMATION_SCHEMA.COLUMNS


The next step was to add the COLUMN_NAME in with a WHERE clause.
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = ‘max_history_rows’


Originally published at https://parvtheitgeek.com on January 29, 2014.