Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to take results from an query and put them into a table

Posted on 2015-01-08
10
Medium Priority
?
155 Views
Last Modified: 2015-01-08
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
0
Comment
Question by:Jass Saini
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 49

Expert Comment

by:Dale Fye
ID: 40538142
The syntax for that would be something like

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).
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40538144
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.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40538153
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Jass Saini
ID: 40538193
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];

Open in new window

0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40538206
Do the Make Table or Append in a different query, based on your above query.
0
 

Author Comment

by:Jass Saini
ID: 40538210
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.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40538211
create a new query (DO NOT select any table), go to SQL view

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

Open in new window

0
 

Author Comment

by:Jass Saini
ID: 40538231
I am getting a Syntax error in From clause
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40538245
if you have saved your crosstab quey, you can use

'create new table

SELECT crosstabquery.* INTO NewTable
FROM  crosstabquery

or
'append to your table
 
INSERT INTO NewTable
SELECT crosstabquery.*
FROM crosstabquery

change  "crosstabquery" with the name of the crosstab query
0
 

Author Closing Comment

by:Jass Saini
ID: 40538248
Thanks Rey....I will try that!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question