Exporting query results to a file

You can export query results data to a file system using the Export Query Results wizard.

Before you begin

To export a query result set to Microsoft Excel correctly, start each Excel formula with “=” in the query.

For example,

SELECT 45.5 AS PRODPRICE, 30 AS AMOUNT, '=A2*B2' AS PRICE
FROM SYSIBM.SYSDUMMY1

About this task

To save query results to a file:

Procedure

  1. Open the Export Query Results wizard in one of the following ways:
    • With a query result set opened in the editor, select File > Export to open the Select page of the Export wizard, and then select Result set from the list of available export wizards.
    • With a query result set opened in the editor, click the Export toolbar button.
  2. From the Source list, select the query result set that you want to export.
    Note: If the query that you are exporting includes several result sets, all of them are displayed in the Source field. Also, if the query includes several result sets, all of them can be exported into one .xls or .xlsx file.
  3. If you are using QMF for Workstation, specify a name for the file that you are creating in the File name field.
    By default, the file is saved in your home directory.
  4. Specify the type of file that you will be creating. Select from the list of available file types in the Export type field. You can choose one of the following file types:
    • Avro (*.avro)
    • Parquet (*.parquet)
    Note: The LOB data in the .avro and .parquet file formats is not exported.
    • PDF (*.pdf)
    • CSV (*.csv)
    • IXF (*.ixf)
    • XML QMF Markup Language file (*.xml)
    • HTML (*.htm)
    • TEXT (*.txt)
    • dbase III (*.dbf)
    • XLS Microsoft Excel 97-2003 (*.xls)
    • XLSX Microsoft Excel 2007 (*.xlsx)
    Note: Some of the fonts (for example, TTC) can be displayed incorrectly in PDF files.
  5. If you selected any option different form XLS or XLSX, click Next. The Second page of the Export Query Results wizard opens. On this page you can select additional options that are available depending on the type of file that you are creating. For example, a dialog is displayed in the wizard for you to enter options for those grayed out choices when you chose DATAFORMAT=TEXT.
  6. If you selected IXF , dbase III, or XML, after setting up the export options, click Next to go the page where you can set up the columns of the exported result set.
    Note: To skip the next step and close the Export Query Results wizard, click Finish.
  7. You can set up the columns by using following options:
    • In the Type column, select a data type from the list.
    • In the Length field, specify a maximum number of characters in a string.
    • In the Precision field, specify a maximum total number of digits for the DECIMAL type.
    • In the Scale field, specify a maximum number of fractional digits for the DECIMAL type.
  8. Click Finish. If you are using QMF for Workstation, a save window specific to your operating system opens. If you are using QMF for WebSphere®, a save window opens that lists the available files for download. Click a hyperlink to download the file to your workstation.