How to export data to .csv file  ?

Hi guys, I know this topic is covered many times in this forum. How do I export my table data to a csv file when my data already has some , (commas) in it. For example, I have two columns in a table, ID and DESCRIPTION. The DESCRIPTION column has data which has , (commas) in it. When I export the data using the following script, I see multiple columns in my excel file as DESCRIPTION has data with commas and each part of it is shown as a separate column in excel sheet.
set heading off
set echo off;
set pause off;
spool tbl_account.csv;
select To_Char(ID)|| ',' || To_Char(Description) From tbl_account;
spool off;
Thanks in advance

Have you thought about putting those values between quotation marks?
"test,test" for example would end up in one cell.
C.

Similar Messages

  • How to export data to csv file on a scheduled basis

    Hi,
    I'm trying to do something that should probably be simple but I just can't figure it out.
    I have an existing MS SQL database (2008 R2). I have a very simple SQL script. I need to run this script on a daily basis and save the results as a .csv file.
    I've tried creating a job in SQL Manager - that didn't work. Then I found a tutorial that had me use MS Visual Studio... couldn't get that to function either.
    Can someone help me understand what program I should be using, and how to go about creating this as a task / job that can run on a scheduled basis?
    Thank you!
    Chris

    Hi, you can follow the below steps to get your work done -
    Create a batch file (.bat) and dump the following text into it
              sqlcmd -S myServer -d myDB -E -Q "select col1, col2, col3 from SomeTable" -o "MyData.csv" -h-1 -s"," -w 700
              Replace myServer with your server name,
    myDB with your Database name and then replace the query with your actual query.
             -h-1 removes column name headers from the result
             -s"," sets the column seperator to ,
             -w 700 sets the row width to 700 chars (this will need to be as wide as the longest row or it will wrap to the next line)
    Save the batch file and the schedule it as per your requirement.
    Hope, that helps.
    -Vinay Pugalia
    If a post answers your question, please click "Mark As Answer" on that post and
    "Mark as Helpful".
    Web : Inkey Solutions
    Blog : My Blog
    Email : Vinay Pugalia

  • How to import data from CSV file with columns separated by semicolon?

    I migrate database from MS SQL 2008 to ORACLE 11g
    I export data to CSV file from MS SQL
    then I try to import it to Oracle
    several tables goes fine using Import data option in the SQL Developer
    Standard CSV files with data separated by comma were imported.
    chars, date (with format string), and integer data are imported via import wizard without problems
    the problems were when I try to import table with noninteger numbers with modal part separated by comma not by dot
    comma is the standard separator for columns in CSV file
    so I must change the standard separator to semicolon
    then the import wizard have problem to correct recognize the columns data because it use only standard CSV comma separator :-/
    In SQL Developer 1.5.3 Tools -> Preferences -> Migration -> Data Move Options
    I change "End of Column Delimiter" to ; but it doens't work
    Is this possible to change the standard column separator for import data wizzard in SQL Developer 1.5.3?
    Or maybe someone know how to import data in SQL Developer 1.5.3 from CSV when CSV colunn separator is set to semicolon?

    A new preference has been added to customize the import delimiter in main code line. This should be available as part of future release.

  • How to export data to .csv and send that file to folder using sql commands?

    Really hoping someone can provide some code sample or point me in the right direction (with examples using sql).
    I am using oracle 11g with plsql developer. My requirement is that the data retrieval should be automatic. That means when query a data in oracle table , the data should be convert into .csv file and then it should send that to some specific folder.
    Example: Assume that student_sub1 table have all students subject1 data.when i write a query like select * from student_sub1 where student=1, the student1 data should convert into .csv file and then the .csv file should go to student1 folder.
    Hence I am requesting you to suggest me how write a sql code to convert the data into .csv file and to create a folder to send that file using oracle.
    Your inputs helps me alot.
    Thanks in advance!!!!
    Waiting for your replies.... Cheers

    981145 wrote:
    Really hoping someone can provide some code sample or point me in the right direction (with examples using sql).
    I am using oracle 11g with plsql developer. My requirement is that the data retrieval should be automatic. That means when query a data in oracle table , the data should be convert into .csv file and then it should send that to some specific folder.
    Example: Assume that student_sub1 table have all students subject1 data.when i write a query like select * from student_sub1 where student=1, the student1 data should convert into .csv file and then the .csv file should go to student1 folder.
    Hence I am requesting you to suggest me how write a sql code to convert the data into .csv file and to create a folder to send that file using oracle.
    Your inputs helps me alot.
    Thanks in advance!!!!
    Waiting for your replies.... CheersSET COLSEP ,
    spool student1.csv
    select * from student_sub1 where student=1;
    spool off
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ
    Handle:     981145
    Status Level:     Newbie
    Registered:     Jan 10, 2013
    Total Posts:     25
    Total Questions:     10 (8 unresolved)
    I extend my condolences to you since you rarely get answers to your questions here.

  • How to saving data in csv file

    I have problem with saving data in csv file. I would like save my data look
    like this example :
    excel preview :
    A B C
    1 10 11 12
    2 13 14 15
    As we see all values are in separate cell A1=10, B1=11, C1=12 ...
    so I try :
    PrintWriter wy = new PrintWriter(new FileWriter("test.csv"));
    values[0][0]="10";
    values[0][1]="11";
    values[0][2]="12";
    values[1][0]="13";
    values[1][1]="14";
    values[1][2]="15";
    for (String[] row : values){
    for (String col : row) {
    wy.print(col + "\t");
    but csv file look like :
    A1=10 11 12
    A2=13 14 15
    but B1-B2 and C1-C2 is empty
    the second steep is use Ostermiller library :
    OutputStream out;
    out = new FileOutputStream("temp.csv");
    CSVPrinter csvp = new CSVPrinter(out);
    String[][] values = new String[2][3];
    csvp.changeDelimiter('\t');
    values[0][0]="10";
    values[0][1]="11";
    values[0][2]="12";
    values[1][0]="13";
    values[1][1]="14";
    values[1][2]="15";
    csvp.println(values);
    but the result is also this same, is anyone do how to resolve this problem
    ?

    but iI don`t want to seperate with comma....value
    I
    want to seperate each value to seperate cellWhen you save the file, separate w/ comma
    When excel loads it, it will automagicarifficallyput
    it in it's own cell.what it is "w/ " ? when I separate my data with
    comma excel don`t put value to spererate cells"w/" is an abbreviation of "with". Post the code that doesn't work, along with the results you get. If it's not working with commas, you must be doing something else wrong.

  • Help Me... How to get Data from CSV File...?

    Hi Everyone..!
    This is yajiv and am working in CS3 Photoshop platform. I know about Java Script. Is it possible to get the data from CSV files. Actually our client use to send us the CSV files which contains a lot of swatch name and reference files in one particular image name.
    Actually how we work on that CSV file is, first we copy file name to search that CSV file. then get the result to paste into layer name. This process continue till the end of swatch.
    Thank in Advance
    -yajiv

    > Is it possible to get the data from CSV files.
    Have you tried searching this forum?

  • Exporting data to csv files

    Please can you help an Oracle newcomer?
    Below is a script (which I took from the forums) that I used to
    run in Lite to export data to a csv file.
    As you can see I am having problems with running the same file
    in 8i - It starts off OK i.e. asking for the name of the table
    but then, instead of completing the full script it executes a
    few lines then keeps asking me for the name of the table. I
    suspect there is something wrng in my environment settings
    (Comments ON etc.) but I have checked everything with no success.
    Any help would be much appreciated as this is a really useful
    script which I use the whole time.
    Thanks very much for your help.
    Regards
    Andrew
    SQL>
    1 SET ECHO OFF
    2 SET FEEDBACK OFF
    3 SET HEADING OFF
    4 SET PAGESIZE 0
    5 SET TIMING OFF
    6 SET VERIFY OFF
    7 ACCEPT name_of_table PROMPT 'Enter the name of the table
    you wish to convert: '
    8 SPOOL query.sql
    9 SELECT 'SPOOL ' || UPPER ('&name_of_table') || '.txt'
    10 FROM DUAL;
    11 SELECT 'SELECT ' || column_name
    12 FROM all_tab_columns
    13 WHERE table_name = UPPER ('&name_of_table')
    14 AND column_id = 1;
    15 SELECT '|| '','' || ' || column_name
    16 FROM all_tab_columns
    17 WHERE table_name = UPPER ('&name_of_table')
    18 AND column_id > 1;
    19 SELECT 'FROM ' || UPPER ('&name_of_table') || ';'
    20 FROM DUAL;
    21 SELECT 'SPOOL OFF'
    22 FROM DUAL;
    23 SPOOL OFF
    24* START query
    25 /
    Enter value for name_of_table: new_table
    old 9: SELECT 'SPOOL ' || UPPER ('&name_of_table') || '.txt'
    new 9: SELECT 'SPOOL ' || UPPER ('new_table') || '.txt'
    Enter value for name_of_table: new_table
    old 13: WHERE table_name = UPPER ('&name_of_table')
    new 13: WHERE table_name = UPPER ('new_table')
    Enter value for name_of_table: new_table
    old 17: WHERE table_name = UPPER ('&name_of_table')
    new 17: WHERE table_name = UPPER ('new_table')
    Enter value for name_of_table: New_table
    old 19: SELECT 'FROM ' || UPPER ('&name_of_table') || ';'
    new 19: SELECT 'FROM ' || UPPER ('New_table') || ';'
    SET ECHO OFF
    ERROR at line 1:
    ORA-00922: missing or invalid option

    Thanks for your help - problem solved I was using Run sql file
    instead of Start sql file - oops!

  • How to store data in .csv file

    Hi...
    I need to export the data in csv format, after retrieving from Database... i am using POI for inserting data from MS Excel to Database... but unable to find any method in POI to store the data in .csv format... need u guys help...
    plz guide me... if there is any method in POI for this purpose or i need to use any other api... (its details)
    Thanks in advance

    corlettk wrote:
    and if it contains two double qoutes?
    Double each of them, of course
    I think someone said that apache has an open source csv reader/writer library... which I presume would conform to the "best open standard" whatever that it is, and hence take care of all this crapolla for you.Very likely. Google will probably turn up a bunch.

  • How to export data in csv

    hai ;
    can u advise me, how to export the value from databse table to csc and pdf format
    please can you provide some sample code
    thanks..

    Doesn't work that way here. Try something, post some code if you get stuck.
    No-one is going to write your code for you.
    You will need to use JDBC to query your database, and there are plenty of CSV libraries available for free, or write your own.

  • How to import data from CSV file into a table by using oracle forms

    Hi,
    I have a CSV file and i want to insert in oracle database in a table by using a button in oracle forms.
    the user can select CSV file by using open dialog .
    can any one help me to find method to make import and select file from the client machine ?
    thx.

    1. create table blob
    CREATE TABLE IB_LOVE
      DOC          BLOB,
      CONTRACT_NO  VARCHAR2(20 BYTE)                NOT NULL
    )2. use the code below to insert:
           INSERT INTO ordmgmt.ib_love
                       (contract_no, doc
                VALUES (:control.contract_no_input, NULL
           lb$result :=
             webutil_file_transfer.client_to_db (:b2.file_name, v_file_blob_name, v_col_blob_name,
                                                 'CONTRACT_NO = ' || :control.contract_no_input);
           :SYSTEM.message_level := 25;
           COMMIT;
           :SYSTEM.message_level := 0;3. use the code below to download
         if :control.CONTRACT_NO_INPUT is not null then
              vboolean :=   webutil_file_transfer.DB_To_Client_With_Progress(
                               vfilename,  --filename                       
                              'IB_LOVE', ---table of Blob item                       
                              'DOC',  --Blob column name                       
                              'CONTRACT_NO = ' || :CONTROL.CONTRACT_NO_INPUT, ---where clause to retrieve the record                       
                              'Downloading from Database', --Progress Bar title                       
                              'Wait to Complete'); --Progress bar subtitle  client_host('cmd /c start '||vfilename);
              client_host('cmd /c start '||vfilename);                 
         else
              errmsg('Please choose contract no');
         end if;4. use the code below to open file dialog
    x:= WEBUTIL_FILE.FILE_OPEN_DIALOG ( 'c:\', '*.gif', '|*.gif|*.gif|', 'My Open Window' ) ;
    :b2.FILE_NAME:=X;

  • How to import data from CSV files to OIM?

    Hello,
    We have to import some of the files which are in csv format and are placed in a specific folder hierarchy. Please help as i am not able to proceed further.
    Thanks a lot!

    To write custom scheduler tasks you need to write a class which extends SchedulerBaseTask class.
    See this link. Re: Custom reconcilation
    Also GTC flat file retrieves data from file and creates identity/account in OIM. You can use either ways to meet your requirements.

  • How to import data from CSV to TCode COR6N

    Hi friends,
    Please help me. I don't know how to import data from CSV file to TCode COR6N. (time ticket for production order)
    I used function: BAPI_PRODORDCONF_CREATE_TT to fill information into TCode COR6n, but it thrown error: "Orders of the order type ZP01 cannot be confirmed". ZP01 is my Order Type.
    Thanks in advance.
    Nguyen Phuoc Toan.

    You can use the LSMW tool to do this.
    The details of LSMW BAPI method is as follows :-
    Business Object:- BUS2116
    Method:-CREATEPREDEFTIMETICKETMULTIPLE
    Message Type:- PPCC2PRETTICKET
    Basic Type:- PPCC2PRETTICKET01
    Regards
    Dhirendra

  • How to import data from CSV to TCode COR1?

    Hi SAP PP guru,
    How to import data from CSV file to TCode COR1?
    Thanks in advance,
    Nguyen Phuoc Toan.

    Nguyen,
    You have not yet confirmed what your requirement is?
    You can take the help of ABAP person to understand what BDC or LSMW is about, basically this is a tool provided by SAP that would enable you to record a transaction process and you can use the code to perform the transaction in mass. [Help on LSMW|http://help.sap.com/erp2005_ehp_04/helpdata/EN/ad/2d54a41d7011d2b42e006094b944c8/content.htm]
    Regards,
    Prasobh

  • Export batch data into CSV file using SQL SP

    Hi,
    I have created WCF-Custom receive adapter to poll Sql SP (WITH xmlnamespaces(DEFAULT 'Namespace' and For XML PATH(''), Type) . Get the result properly in batch while polling and but getting error while converting into CSV by using map.
    Please can anyone give me some idea to export SQL data into CSV file using SP.

    How are you doing this.
    You would have got XML representation for the XML batch received from SQL
    You should have a flat-file schema representing the CSV file which you want to send.
    Map the received XML representation of data from SQL to flat-file schema
    have custom pipeline with flat-file assembler on the assembler stage of the send pipeline.
    In the send port use the map which convert received XML from SQL to flat file schema and use the above custom flat-file disassembler send port
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • How to export data from a Oracle table to a delimited file?

    I know how to load delimited file into a table, but how to export
    data from a Oracle table to a delimited file?
    Thanks in advance.

    Try looking at this link, it's long but there's three different solutions discussed in it. If you look at Barbara Boehmer's
    solution in her posts in the link below you'll see that she's addressed your concerns with spool files.
    Re: utl_smtp and triggers

Maybe you are looking for

  • Why do I have extra songs in my iPhone playlist that are not on my iTunes library?

    After doing the iOS7 update (and iOS7.0.2) I decided to add my music to my phone (I never had music on it before). I discovered that there were 20 very random and obscure broadway songs that were on my iPhone in addition to the 60 songs I just synced

  • Ipod touch not being reconized in itunes, it keeps coming up as a camera ? windows xp.

    ipod touch not being reconized in itunes but keeps coming up as a camera ? i'm using windows xp. any ideas to resolve this problem ???

  • Itunes lack of apple tv options

    I have an Apple TV Generation one. It appears in my Itunes 11 but i only have two options "Settings" and "Photos", however the settings option doesn't seem to work. Because I feel like it should still have the option to sync music and playlists. Howe

  • Exporting compiled forms to CSV file

    In trying to export a small batch of compiled forms, I noticed that the data in the first column (form name) does not line up with the data actually on the form when they are exported.  Any ideas on how to fix that?  They match in the dataset, but no

  • CC 2014 Installation

    Bin gerade dabei von CC auf CC 2014 upzugraden. Nach dem das Update von Photoshop CC 2014 nicht möglich war wegen Exit Code: 7 habe ich die komplette CC deinstalliert und wollte es jetzt neu installieren. Leider kann ich keines der Tools, bis auf Mus