azzazzello
Technical User
I have X number of identical (structure-wise) tables, with one generated for every day. There is a reporting tool which requires that certain data be extracted for a given time period, which can span any number of these databases. My idea is to use a dynamically generated UNION ALL statement which simply joins identical selects for each table. e.g.
Here is a problem...Suppose I have a SELECT * statement that I need to do this to, and my table structure changes (which is plausibly can). Then a query using "SELECT *" is run, and it spans the 2 different-structure databases. The statement will fail, which is bad. Is there something I can do other than iterating through each table in my code? (which I am reluctant to do)
Code:
SELECT id, blah, bleh FROM t1
UNION ALL
SELECT id, blah, bleh FROM t2
....
Here is a problem...Suppose I have a SELECT * statement that I need to do this to, and my table structure changes (which is plausibly can). Then a query using "SELECT *" is run, and it spans the 2 different-structure databases. The statement will fail, which is bad. Is there something I can do other than iterating through each table in my code? (which I am reluctant to do)