Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining multiple identical tables into one

Status
Not open for further replies.

rpatel18

IS-IT--Management
Jun 15, 2007
32
0
0
US
I have 51 tables(all 50 states plus DC), all with identical fields. I want to create a table that combines them all into one table but can't seem to figure it out. Heres is a test code that I tried to run but get an error "too many fields"

INSERT INTO [IRS '98]
SELECT a.ZipCode1998, a.NumberofReturns1998, a.TotalExemptions1998, a.DependentExemptions1998, a.AGI1998, a.ReturnsSalariesWages1998, a.AmountSalaryWages1998, a.ReturnsTaxableInterest1998, a.AmountTaxableInterest1998, a.ReturnsEIC1998, a.AmountEIC1998, a.ReturnsTotalTax1998, a.AmountTotalTax1998, a.ReturnsScheduleC1998, a.TotalScheduleC1998, a.ReturnsScheduleF1998, a.TotalScheduleF1998, a.ReturnsScheduleA1998, a.AmountScheduleA1998, a.NumberofReturns1998_U10K, a.TotalExemptions1998_U10K, a.DependentExemptions1998_U10K, a.AGI1998_U10K, a.ReturnsSalariesWages1998_U10K, a.AmountSalaryWages1998_U10K, a.ReturnsTaxableInterest1998_U10K, a.AmountTaxableInterest1998_U10K, a.ReturnsEIC1998_U10K, a.AmountEIC1998_U10K, a.ReturnsTotalTax1998_U10K, a.AmountTotalTax1998_U10K, a.ReturnsScheduleC1998_U10K, a.TotalScheduleC1998_U10K, a.ReturnsScheduleF1998_U10K, a.TotalScheduleF1998_U10K, a.ReturnsScheduleA1998_U10K, a.AmountScheduleA1998_U10K, a.NumberofReturns1998_10KU25K, a.TotalExemptions1998_10KU25K, a.DependentExemptions1998_10KU25K, a.AGI1998_10KU25K, a.ReturnsSalariesWages1998_10KU25K, a.AmountSalaryWages1998_10KU25K, a.ReturnsTaxableInterest1998_10KU25K, a.AmountTaxableInterest1998_10KU25K, a.ReturnsEIC1998_10KU25K, a.AmountEIC1998_10KU25K, a.ReturnsTotalTax1998_10KU25K, a.AmountTotalTax1998_10KU25K, a.ReturnsScheduleC1998_10KU25K, a.TotalScheduleC1998_10KU25K, a.ReturnsScheduleF1998_10KU25K, a.TotalScheduleF1998_10KU25K, a.ReturnsScheduleA1998_10KU25K, a.AmountScheduleA1998_10KU25K, a.NumberofReturns1998_25KU50K, a.TotalExemptions1998_25KU50K, a.DependentExemptions1998_25KU50K, a.AGI1998_25KU50K, a.ReturnsSalariesWages1998_25KU50K, a.AmountSalaryWages1998_25KU50K, a.ReturnsTaxableInterest1998_25KU50K, a.AmountTaxableInterest1998_25KU50K, a.ReturnsEIC1998_25KU50K, a.AmountEIC1998_25KU50K, a.ReturnsTotalTax1998_25KU50K, a.AmountTotalTax1998_25KU50K, a.ReturnsScheduleC1998_25KU50K, a.TotalScheduleC1998_25KU50K, a.ReturnsScheduleF1998_25KU50K, a.TotalScheduleF1998_25KU50K, a.ReturnsScheduleA1998_25KU50K, a.AmountScheduleA1998_25KU50K, a.NumberofReturns1998_50K, a.TotalExemptions1998_50K, a.DependentExemptions1998_50K, a.AGI1998_50K, a.ReturnsSalariesWages1998_50K, a.AmountSalaryWages1998_50K, a.ReturnsTaxableInterest1998_50K, a.AmountTaxableInterest1998_50K, a.ReturnsEIC1998_50K, a.AmountEIC1998_50K, a.ReturnsTotalTax1998_50K, a.AmountTotalTax1998_50K, a.ReturnsScheduleC1998_50K, a.TotalScheduleC1998_50K, a.ReturnsScheduleF1998_50K, a.TotalScheduleF1998_50K, a.ReturnsScheduleA1998_50K, a.AmountScheduleA1998_50K
FROM
(
SELECT ZipCode1998, NumberofReturns1998, TotalExemptions1998, DependentExemptions1998, AGI1998, ReturnsSalariesWages1998, AmountSalaryWages1998, ReturnsTaxableInterest1998, AmountTaxableInterest1998, ReturnsEIC1998, AmountEIC1998, ReturnsTotalTax1998, AmountTotalTax1998, ReturnsScheduleC1998, TotalScheduleC1998, ReturnsScheduleF1998, TotalScheduleF1998, ReturnsScheduleA1998, AmountScheduleA1998, NumberofReturns1998_U10K, TotalExemptions1998_U10K, DependentExemptions1998_U10K, AGI1998_U10K, ReturnsSalariesWages1998_U10K, AmountSalaryWages1998_U10K, ReturnsTaxableInterest1998_U10K, AmountTaxableInterest1998_U10K, ReturnsEIC1998_U10K, AmountEIC1998_U10K, ReturnsTotalTax1998_U10K, AmountTotalTax1998_U10K, ReturnsScheduleC1998_U10K, TotalScheduleC1998_U10K, ReturnsScheduleF1998_U10K, TotalScheduleF1998_U10K, ReturnsScheduleA1998_U10K, AmountScheduleA1998_U10K, NumberofReturns1998_10KU25K, TotalExemptions1998_10KU25K, DependentExemptions1998_10KU25K, AGI1998_10KU25K, ReturnsSalariesWages1998_10KU25K, AmountSalaryWages1998_10KU25K, ReturnsTaxableInterest1998_10KU25K, AmountTaxableInterest1998_10KU25K, ReturnsEIC1998_10KU25K, AmountEIC1998_10KU25K, ReturnsTotalTax1998_10KU25K, AmountTotalTax1998_10KU25K, ReturnsScheduleC1998_10KU25K, TotalScheduleC1998_10KU25K, ReturnsScheduleF1998_10KU25K, TotalScheduleF1998_10KU25K, ReturnsScheduleA1998_10KU25K, AmountScheduleA1998_10KU25K, NumberofReturns1998_25KU50K, TotalExemptions1998_25KU50K, DependentExemptions1998_25KU50K, AGI1998_25KU50K, ReturnsSalariesWages1998_25KU50K, AmountSalaryWages1998_25KU50K, ReturnsTaxableInterest1998_25KU50K, AmountTaxableInterest1998_25KU50K, ReturnsEIC1998_25KU50K, AmountEIC1998_25KU50K, ReturnsTotalTax1998_25KU50K, AmountTotalTax1998_25KU50K, ReturnsScheduleC1998_25KU50K, TotalScheduleC1998_25KU50K, ReturnsScheduleF1998_25KU50K, TotalScheduleF1998_25KU50K, ReturnsScheduleA1998_25KU50K, AmountScheduleA1998_25KU50K, NumberofReturns1998_50K, TotalExemptions1998_50K, DependentExemptions1998_50K, AGI1998_50K, ReturnsSalariesWages1998_50K, AmountSalaryWages1998_50K, ReturnsTaxableInterest1998_50K, AmountTaxableInterest1998_50K, ReturnsEIC1998_50K, AmountEIC1998_50K, ReturnsTotalTax1998_50K, AmountTotalTax1998_50K, ReturnsScheduleC1998_50K, TotalScheduleC1998_50K, ReturnsScheduleF1998_50K, TotalScheduleF1998_50K, ReturnsScheduleA1998_50K, AmountScheduleA1998_50K
FROM [AK IRS] UNION
SELECT ZipCode1998, NumberofReturns1998, TotalExemptions1998, DependentExemptions1998, AGI1998, ReturnsSalariesWages1998, AmountSalaryWages1998, ReturnsTaxableInterest1998, AmountTaxableInterest1998, ReturnsEIC1998, AmountEIC1998, ReturnsTotalTax1998, AmountTotalTax1998, ReturnsScheduleC1998, TotalScheduleC1998, ReturnsScheduleF1998, TotalScheduleF1998, ReturnsScheduleA1998, AmountScheduleA1998, NumberofReturns1998_U10K, TotalExemptions1998_U10K, DependentExemptions1998_U10K, AGI1998_U10K, ReturnsSalariesWages1998_U10K, AmountSalaryWages1998_U10K, ReturnsTaxableInterest1998_U10K, AmountTaxableInterest1998_U10K, ReturnsEIC1998_U10K, AmountEIC1998_U10K, ReturnsTotalTax1998_U10K, AmountTotalTax1998_U10K, ReturnsScheduleC1998_U10K, TotalScheduleC1998_U10K, ReturnsScheduleF1998_U10K, TotalScheduleF1998_U10K, ReturnsScheduleA1998_U10K, AmountScheduleA1998_U10K, NumberofReturns1998_10KU25K, TotalExemptions1998_10KU25K, DependentExemptions1998_10KU25K, AGI1998_10KU25K, ReturnsSalariesWages1998_10KU25K, AmountSalaryWages1998_10KU25K, ReturnsTaxableInterest1998_10KU25K, AmountTaxableInterest1998_10KU25K, ReturnsEIC1998_10KU25K, AmountEIC1998_10KU25K, ReturnsTotalTax1998_10KU25K, AmountTotalTax1998_10KU25K, ReturnsScheduleC1998_10KU25K, TotalScheduleC1998_10KU25K, ReturnsScheduleF1998_10KU25K, TotalScheduleF1998_10KU25K, ReturnsScheduleA1998_10KU25K, AmountScheduleA1998_10KU25K, NumberofReturns1998_25KU50K, TotalExemptions1998_25KU50K, DependentExemptions1998_25KU50K, AGI1998_25KU50K, ReturnsSalariesWages1998_25KU50K, AmountSalaryWages1998_25KU50K, ReturnsTaxableInterest1998_25KU50K, AmountTaxableInterest1998_25KU50K, ReturnsEIC1998_25KU50K, AmountEIC1998_25KU50K, ReturnsTotalTax1998_25KU50K, AmountTotalTax1998_25KU50K, ReturnsScheduleC1998_25KU50K, TotalScheduleC1998_25KU50K, ReturnsScheduleF1998_25KU50K, TotalScheduleF1998_25KU50K, ReturnsScheduleA1998_25KU50K, AmountScheduleA1998_25KU50K, NumberofReturns1998_50K, TotalExemptions1998_50K, DependentExemptions1998_50K, AGI1998_50K, ReturnsSalariesWages1998_50K, AmountSalaryWages1998_50K, ReturnsTaxableInterest1998_50K, AmountTaxableInterest1998_50K, ReturnsEIC1998_50K, AmountEIC1998_50K, ReturnsTotalTax1998_50K, AmountTotalTax1998_50K, ReturnsScheduleC1998_50K, TotalScheduleC1998_50K, ReturnsScheduleF1998_50K, TotalScheduleF1998_50K, ReturnsScheduleA1998_50K, AmountScheduleA1998_50K
FROM [AL IRS] UNION
SELECT ZipCode1998, NumberofReturns1998, TotalExemptions1998, DependentExemptions1998, AGI1998, ReturnsSalariesWages1998, AmountSalaryWages1998, ReturnsTaxableInterest1998, AmountTaxableInterest1998, ReturnsEIC1998, AmountEIC1998, ReturnsTotalTax1998, AmountTotalTax1998, ReturnsScheduleC1998, TotalScheduleC1998, ReturnsScheduleF1998, TotalScheduleF1998, ReturnsScheduleA1998, AmountScheduleA1998, NumberofReturns1998_U10K, TotalExemptions1998_U10K, DependentExemptions1998_U10K, AGI1998_U10K, ReturnsSalariesWages1998_U10K, AmountSalaryWages1998_U10K, ReturnsTaxableInterest1998_U10K, AmountTaxableInterest1998_U10K, ReturnsEIC1998_U10K, AmountEIC1998_U10K, ReturnsTotalTax1998_U10K, AmountTotalTax1998_U10K, ReturnsScheduleC1998_U10K, TotalScheduleC1998_U10K, ReturnsScheduleF1998_U10K, TotalScheduleF1998_U10K, ReturnsScheduleA1998_U10K, AmountScheduleA1998_U10K, NumberofReturns1998_10KU25K, TotalExemptions1998_10KU25K, DependentExemptions1998_10KU25K, AGI1998_10KU25K, ReturnsSalariesWages1998_10KU25K, AmountSalaryWages1998_10KU25K, ReturnsTaxableInterest1998_10KU25K, AmountTaxableInterest1998_10KU25K, ReturnsEIC1998_10KU25K, AmountEIC1998_10KU25K, ReturnsTotalTax1998_10KU25K, AmountTotalTax1998_10KU25K, ReturnsScheduleC1998_10KU25K, TotalScheduleC1998_10KU25K, ReturnsScheduleF1998_10KU25K, TotalScheduleF1998_10KU25K, ReturnsScheduleA1998_10KU25K, AmountScheduleA1998_10KU25K, NumberofReturns1998_25KU50K, TotalExemptions1998_25KU50K, DependentExemptions1998_25KU50K, AGI1998_25KU50K, ReturnsSalariesWages1998_25KU50K, AmountSalaryWages1998_25KU50K, ReturnsTaxableInterest1998_25KU50K, AmountTaxableInterest1998_25KU50K, ReturnsEIC1998_25KU50K, AmountEIC1998_25KU50K, ReturnsTotalTax1998_25KU50K, AmountTotalTax1998_25KU50K, ReturnsScheduleC1998_25KU50K, TotalScheduleC1998_25KU50K, ReturnsScheduleF1998_25KU50K, TotalScheduleF1998_25KU50K, ReturnsScheduleA1998_25KU50K, AmountScheduleA1998_25KU50K, NumberofReturns1998_50K, TotalExemptions1998_50K, DependentExemptions1998_50K, AGI1998_50K, ReturnsSalariesWages1998_50K, AmountSalaryWages1998_50K, ReturnsTaxableInterest1998_50K, AmountTaxableInterest1998_50K, ReturnsEIC1998_50K, AmountEIC1998_50K, ReturnsTotalTax1998_50K, AmountTotalTax1998_50K, ReturnsScheduleC1998_50K, TotalScheduleC1998_50K, ReturnsScheduleF1998_50K, TotalScheduleF1998_50K, ReturnsScheduleA1998_50K, AmountScheduleA1998_50K
FROM [CA IRS] UNION
SELECT ZipCode1998, NumberofReturns1998, TotalExemptions1998, DependentExemptions1998, AGI1998, ReturnsSalariesWages1998, AmountSalaryWages1998, ReturnsTaxableInterest1998, AmountTaxableInterest1998, ReturnsEIC1998, AmountEIC1998, ReturnsTotalTax1998, AmountTotalTax1998, ReturnsScheduleC1998, TotalScheduleC1998, ReturnsScheduleF1998, TotalScheduleF1998, ReturnsScheduleA1998, AmountScheduleA1998, NumberofReturns1998_U10K, TotalExemptions1998_U10K, DependentExemptions1998_U10K, AGI1998_U10K, ReturnsSalariesWages1998_U10K, AmountSalaryWages1998_U10K, ReturnsTaxableInterest1998_U10K, AmountTaxableInterest1998_U10K, ReturnsEIC1998_U10K, AmountEIC1998_U10K, ReturnsTotalTax1998_U10K, AmountTotalTax1998_U10K, ReturnsScheduleC1998_U10K, TotalScheduleC1998_U10K, ReturnsScheduleF1998_U10K, TotalScheduleF1998_U10K, ReturnsScheduleA1998_U10K, AmountScheduleA1998_U10K, NumberofReturns1998_10KU25K, TotalExemptions1998_10KU25K, DependentExemptions1998_10KU25K, AGI1998_10KU25K, ReturnsSalariesWages1998_10KU25K, AmountSalaryWages1998_10KU25K, ReturnsTaxableInterest1998_10KU25K, AmountTaxableInterest1998_10KU25K, ReturnsEIC1998_10KU25K, AmountEIC1998_10KU25K, ReturnsTotalTax1998_10KU25K, AmountTotalTax1998_10KU25K, ReturnsScheduleC1998_10KU25K, TotalScheduleC1998_10KU25K, ReturnsScheduleF1998_10KU25K, TotalScheduleF1998_10KU25K, ReturnsScheduleA1998_10KU25K, AmountScheduleA1998_10KU25K, NumberofReturns1998_25KU50K, TotalExemptions1998_25KU50K, DependentExemptions1998_25KU50K, AGI1998_25KU50K, ReturnsSalariesWages1998_25KU50K, AmountSalaryWages1998_25KU50K, ReturnsTaxableInterest1998_25KU50K, AmountTaxableInterest1998_25KU50K, ReturnsEIC1998_25KU50K, AmountEIC1998_25KU50K, ReturnsTotalTax1998_25KU50K, AmountTotalTax1998_25KU50K, ReturnsScheduleC1998_25KU50K, TotalScheduleC1998_25KU50K, ReturnsScheduleF1998_25KU50K, TotalScheduleF1998_25KU50K, ReturnsScheduleA1998_25KU50K, AmountScheduleA1998_25KU50K, NumberofReturns1998_50K, TotalExemptions1998_50K, DependentExemptions1998_50K, AGI1998_50K, ReturnsSalariesWages1998_50K, AmountSalaryWages1998_50K, ReturnsTaxableInterest1998_50K, AmountTaxableInterest1998_50K, ReturnsEIC1998_50K, AmountEIC1998_50K, ReturnsTotalTax1998_50K, AmountTotalTax1998_50K, ReturnsScheduleC1998_50K, TotalScheduleC1998_50K, ReturnsScheduleF1998_50K, TotalScheduleF1998_50K, ReturnsScheduleA1998_50K, AmountScheduleA1998_50K
FROM [CO IRS]
) a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top