Jass Saini
asked on
How to take results from an query and put them into a table
Hello,
I ran a query and would like the results of the query to into the table....I need to do this each time I run the query
I ran a query and would like the results of the query to into the table....I need to do this each time I run the query
Do you mean a new table or an existing table?
Go to Design Mode and
- If the former, click on "Make Table".
- If the latter, click on "Append".
Enter the table name.
Go to Design Mode and
- If the former, click on "Make Table".
- If the latter, click on "Append".
Enter the table name.
I'll assume you are running a SELECT query
in design view of your query, change your SELECT query into an APPEND query
select the Destination table from the dropdown in the Append window
select the destination fields in the
Append to: row of the query
in design view of your query, change your SELECT query into an APPEND query
select the Destination table from the dropdown in the Append window
select the destination fields in the
Append to: row of the query
ASKER
Here is my query
TRANSFORM Sum(Final_Table.[Total Initial]) AS [SumOfTotal Initial]
SELECT Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
FROM Final_Table
GROUP BY Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
PIVOT Final_Table.[Line Item];
Do the Make Table or Append in a different query, based on your above query.
ASKER
Rey,
I tried that ...I have 900 records and this is a crosstab and when I change to an append query...it wanted to append 7124 records. That not what I want.
I tried that ...I have 900 records and this is a crosstab and when I change to an append query...it wanted to append 7124 records. That not what I want.
create a new query (DO NOT select any table), go to SQL view
copy the below sql and paste to the new query
copy the below sql and paste to the new query
select A.* Into NewTable
From
(
TRANSFORM Sum(Final_Table.[Total Initial]) AS [SumOfTotal Initial]
SELECT Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
FROM Final_Table
GROUP BY Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
PIVOT Final_Table.[Line Item]
) As A
ASKER
I am getting a Syntax error in From clause
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Rey....I will try that!
INSERT INTO TableB (Field1, Field2, Field3)
SELECT Field1, Field2, Field3
FROM TableA
WHERE Field1 = 2
All you really need to do is add the INSERT line, with the name of the table you want to append to, and the fields you want to place the output of your query in. Making sure that the field types in TableB and the query must match (but the field names do not have to).