Can I get a copy of the contents of an SQL result set?

I need to get a copy of the contents of an SQL result set.  I want to either put it in a spreadsheet or save it to a file.

 

There are several ways to copy and/or save the data from a result set grid.  Once you get the results of your query, use your mouse to select the data you want copied or saved.  Next, right-click in the upper-left box in the grid as shown below.

A pop-up menu with your options will appear:

 

 

Notice one of the options is Select All.  Choosing this option selects all of the data in the grid (if you didn’t do it previously). 

The Copy and Copy with Headers copies the data (optionally with headers), but without the grid lines.

Selecting Copy – this option just provides the data.
ORD001 ITEM001 1.00 1 1.00
ORD001 ITEM002 2.00 3 6.00
ORD002 ITEM003 3.00 5 15.00


Selecting Copy with Headers – this option provides headers and data.

ORDERID ITEMNMBR UNITPRICE QUANTITY EXTENDEDPRICE
ORD001 ITEM001 1.00 1 1.00
ORD001 ITEM002 2.00 3 6.00
ORD002 ITEM003 3.00 5 15.00

Notice that the data columns do not appear to be lined up with the column headers.  This is because of tabs and spacing.  If you were to paste the copied data into a spreadsheet, the data would line up under the headers:

 

Selecting Save Results As – This allows you to save the data into a file in either CSV (Comma delimited) or Text (Tab delimited) format.  You will be prompted for the location and file name.

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences