SQL – Turning Several Result Sets into a Single Result Set

In case you need to get several result sets through a single result set, for whatever reason. In my case I have program that works on one result set at a time that needed some aggregate data displayed at the end of the report. Here is what you do:

Create a temporary table to store the table with the most fields in your result set. Everything will use this table for its data. Be sure create a primary key using an int identity(1,1). Without creating a primary key the data will not be stored in any order.

Order the data the way you need it to display and insert it into the temporary table. Then add following result sets to this table.

Note: Data types are important in getting this to work and character/string based data types tend to work the best.

Computers Blogs