I'm trying to execute the query below... I has been running for more than one hour, and my computer is not too responsive anymore. I'm just trying to put these 26 tables that contain the same data (different months) into one table.
Each table has about 50,000 lines. So the total would have around 1.2 millions lines, which is not that huge. My Access DB is around 600 megs before the union...
What's the best way to create this master table if union doesn't work? Append maybe?
Suggestions are appreciated.
Thank you.
SELECT * INTO Item_Sales
FROM (
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Apr_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Apr_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Aug_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Aug_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Dec_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Dec_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Feb_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Feb_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jan_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jan_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jul_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jul_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Mar_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Mar_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Nov_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Nov_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Oct_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Oct_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Sep_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Sep_2010_f );
Each table has about 50,000 lines. So the total would have around 1.2 millions lines, which is not that huge. My Access DB is around 600 megs before the union...
What's the best way to create this master table if union doesn't work? Append maybe?
Suggestions are appreciated.
Thank you.
SELECT * INTO Item_Sales
FROM (
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Apr_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Apr_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Aug_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Aug_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Dec_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Dec_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Feb_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Feb_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jan_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jan_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jul_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jul_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Jun_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Mar_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Mar_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM May_2011_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Nov_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Nov_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Oct_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Oct_2010_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Sep_2009_f UNION
SELECT *, ITEM_NUMBER & '_' & PRODUCT & '_' & LOC AS IPL, ITEM_NUMBER & '_' & PRODUCT AS IP FROM Sep_2010_f );