I am merging a few tables and I need to query for specific column names. Reason being these tables I am condensing have FK candidate columns but no FK so I would have to keep looking through every table to see if it contained a specific column name and that seems to be wearing on the eyes a little.
I got this from another post but it is not complete.
SELECT 'SELECT ''' + TABLE_NAME + '.' + column_name +
''' FROM ' + TABLE_NAME + ' WHERE ' +
column_name + ' = ''[THE COLUMN NAME I AM LOOKING FOR]'''
FROM INFORMATION_SCHEMA.COLUMNS
The TSQL above seems to not be structured correctly or I am missing something.