I am looking to have a query that can pull the values of certain columns from certain tables. I would like this to be as flexible as possible however so as we add more of these tables the query wouldn't need to be changed. So essentially something like this:
Code: Select all
Select (SELECT COLUMN_NAME
FROM _V_SYS_COLUMNS
WHERE
TABLE_NAME like 'XFMD%'
AND SCHEMA = 'ADMIN'
AND COLUMN_NAME like '%BK') as Column_Name
FROM (SELECT DISTINCT TABLE_NAME
FROM _V_SYS_COLUMNS
WHERE
TABLE_NAME like 'XFMD%'
AND DATABASE = 'VALHALLA'
AND SCHEMA = 'ADMIN') as Source_Table