I have a query that spits out multiple result tables and I want to be able to select all of the tables at once, hit copy and then paste them all to one Excel file all at the same time. I would also be ok with exporting, if someone knows how to do that.

Note: I do not want to change the default settings, just want to be able to do this for this one query.

Update: I should have specified in my original question that the column in different tables do not match.

  • Just clarify, what you mean default settings? – Siva Charan Oct 8 '12 at 18:24
  • I want to be able to use this only the query in question, and not have to use the solution as a blanket solution. In other words, I don't wan to change the behaviors in Tools > Options > Query Results. – tarheel Oct 8 '12 at 18:40

If all your columns are the same in each sub query, then you can put a UNION ALL between them and they will all append to the same query. The columns all have to be the same names and in the same order for this to work. If they are close but not exact, you can do things like add empty columns to one query so it will match another query. For example, if the first query has Name, Rank and Serial for the results, but the second query only has Name and Serial, you can write it like this:

SELECT Name, Rank, Serial
FROM Table_A
SELECT Name, '' AS Rank, Serial
FROM Table_B
  • Have to give you props for such a good and useful answer when that situation comes about. Unfortunately, in my current issue the column names are unrelated between result tables. – tarheel Oct 8 '12 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.