Hi Folks
I have a scenario where I need to regularly load 6 tables into a master table. Each of the 6 tables represents 1 months of sales. I only need to load the 6 most recent Sales tables each month. So an example would be
- Sales Jan 2012
- Sales Feb 2012
- Sales Mar 2012
- Sales Apr 2012
- Sales May 2012
- Sales June 2012
Each month a new sales table is produced. So the next month I would want to load the following tables.
- Sales Feb 2012
- Sales Mar 2012
- Sales Apr 2012
- Sales May 2012
- Sales June 2012
- Sales July 2012
The tables older than 6 months, e.g " Sales Jan 2012" still remain in the database, but I just don't need to load it into the master table once it is older than 6 months old.
I am assuming this is best done with some sort of looping logic where
- I make a connection to the database containing the Sales tables
- I define the number of tables to load (a static number, 6).
Can someone
1) let me know the best approach to do this (For each Loop, Each loop, or some other approach)
2) point me in the direction of a good example of how to do this?
Regards
Steve