Jay
Mar 16, 2018 11:00:38 AM

Create output file from query results

Hi. Is there a way to create an output file as part of the query so I don't have to the right mouse click export option?

I found a "INTO OUTFILE" code online but when I use it as in the example I found I get "FROM keyword not found where expected".

This is my query with the INTO OUTFILE code. Runs fine if I don't use that code.

Thanks

Select
supplier_proc_id,
rx_chnl_cd channel_key,
rx_cnt Rx_count,
rx_typ_cd Rx_Type,
rx_dspnsd_qty Rx_Qty

INTO OUTFILE 'C:\Users\JVILLAVERDE\Documents\WinSQL\UDA Rx Impacts\uda_test.txt'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

FROM UDA_RX_TRANS



Synametrics support engineer
Mar 16, 2018 11:25:02 AM

Create output file from query results

Jay,

The INTO OUTFILE syntax is not a generic export method. It is a server-side method that is only support by certain back-end RDBMS, such as MySQL. Addtionally, the path you specified "C:\Users\JVillaverde... also refers to a disk on the server, not on the client. Therefore, this method will not work in WinSQL.

If you end goal is to export the result of the SQL query to a CSV file, WinSQL offers a few method:

  • Run the query in Grid. Then, click the right mouse button and select Export Data... from the popup menu
  • Select Import/Export under Query (on the main menu). This will open the Export Wizard, allowing you to export to several destinations. This is the most flexible method
  • Another quick and dirty way is to write a special comment right before the query:

    -- wn_SaveToCSV C:\Users\JVillaverde\Documents\WinSQL\uda_test.txt
    SELECT supplier_proc_id, ... From UDA_RX_TRANS

    This method will save the results of the query to the uda_test.txt file you specified.


Ruki
Oct 1, 2018 7:42:41 PM

Create output file from query results

Ive tried both ways mentioned above and neither are working for me.

When i try the export wizard the whole systems just does nothing and winsql crashed and nothing gets exported not sure why this is happening.



Synametrics support engineer
Oct 2, 2018 10:39:18 AM

Create output file from query results

Ruki,

Could you please call our support number and talk to one of our engineers. We may have to do a remote screen share session to see what is causing this issue. Our phone number is +1-609-750-0007 x2

Navigation

Social Media

Powered by 10MinutesWeb.com