It is very hard to believe that ETL jobs in production keep creating/dropping permanent or global temporary tables. Volatile tables do not get written into data dictionary, so those should not come up in your query results.
I would like to suggest few things.
1) as you know the exact name of the column (surrogate key) then do not use LIKE %..% while reading from dbc.columns but use the exact name to avoid the chances of similar kinds of columns anywhere in the database.
2) if you do not want global temporary tables in your query result then you can filter like -
SEL * FROM dbc.tables WHERE requesttext NOT LIKE '%global temp%'
3) Try to run your query when minimum or none ETL jobs are running.
Good luck !
↧