SELECT 'SELECT '||'T.'||'"'||column_name||'"'||E'\n'||' FROM '||'"'||table_schema||'"'||'.'||'"'||table_name||'"'||' T'||E'\n'|| ' INNER JOIN "DBACHECKDB"."AddressIDLog" A ON A."AddressID"=T.'||'"'||column_name||'"'||E'\n'|| 'UNION ALL' FROM information_schema.columns WHERE column_name LIKE '%AddressID%' AND is_updatable = 'YES' AND NOT table_schema ='DBACHECKDB'