Need to write query results to .xls file

Hi All,
My requirement is ,when i run a query from sqlplus the results should be copied to a excel sheet.But i am not able to generate the file in the correct format.Could some body please help on this..
Thanks in advance
Thanks
[email protected]

Could some body please help on this..I am sorry to see that GOOGLE, SEARCH & HELP are broken for you.
Please be patient while repairs are completed.
Additional information will be posted when it becomes available.

Similar Messages

  • Write big query results into a file  ? ?  ?

    Hi all,
    The problem is: I want to write a simple query results into a file. I have no idea how to do that. Only thing I know is utl_ functions. Please advise GURUS how can I use them for big queries. Any example will be really appreciable.
    Thank you in advance.
    Message was edited by:
    v838

    hi,
    i´ld do it like that:
    filedir     varchar2(30):= '/usr/frajo/';
    filename     varchar2(30):= 'file.txt';
    fhandle     utl_file.file_type;
    cursor x is
    select ... (what ever)
    begin
         fhandle := utl_file.fopen (filedir, filename,'a');
         open x;
         loop
              fetch x into (what ever)
              exit when x%notfound;
              utl_file.put_line (fhandle,'text and you results');
         end loop;
         utl_file.fclose(fhandle);
    end;
    happy xmas. franz

  • Query results to a file

    I have a requirement to put the query result in a file(.csv),
    Pls let me know is there a possibility to achieve this using dbms_output package
    Thanks

    859486 wrote:
    I have a requirement to put the query result in a file(.csv),
    Pls let me know is there a possibility to achieve this using dbms_output packageNo. The DBMS_OUTPUT package is almost ALWAYS the wrong package to use. It is the most misunderstood and most frequently abused piece of PL/SQL software. So no - it is not suited in anyway to spool CSV output. In fact, trying it with a large SQLdataset can crash the Oracle server - as memory will be exhausted and the swap daemons will trash CPU utilisation.
    To read or write a physical o/s file - the typical package used is UTL_FILE. It is fairly easy using UTL_FILE to create a CSV file.
    However, there could be far better alternatives. The CSV file may be needed by a web client - in which case the file can be created as a CLOB and provided as a Mime text/csv data stream to a web browser (which usually will automatically open in Excel).
    The CSV file may need to be delivered via e-mail. In which case, the CSV file contents can be delivered via UTL_SMTP to a mail server as an e-mail attachment.
    The CSV file may be needed to be delivered to a remote server. In which case the CSV file can be created as a CLOB and this CLOB can be ftp'ed via PL/SQL to the remote server as a text file.
    So there are many options in creating and delivering a CSV file. Using DBMS_OUTPUT though is not a sensible option - ever.

  • How to save query result on the file server as excel file?

    Hi everyone,
    I need to save the the query result on the file server as excel file.
    Do you have any idees how can I do it?
    Regards
    Erwin

    i dont think you can save as excel file but you can save it as CSV use APD or RSCRM BAPI for this

  • Export query result to txt file

    Hello,
    I'm trying to export a query result to txt file but I facing some problems.
    I'm using the comand below:
    set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on
    set colsep ,
    spool C:\estados.txt
    select id_estado,cod_estado,nme_estado from tb_estado;
    spool off
    First problem: My select statement is being writen on my estados.txt
    Second problem: The results are being writen with a lot of blank spaces in start of line, for example, instead of write "1,AC,Acre" the line is write as " 1,AC,Acre".
    Third problem: The "spool off" statement is being written on my estados.txt
    How could I solve it?
    Thanks

    1. Works here - what version of SQL*PLUS are you using?
    2. If you want to prevent spaces, you have to write your SELECT like this:
    select id_estado || ',' || cod_estado || ',' || nme_estado from tb_estado;Note: not tested.
    3. See 1.
    C.

  • How to save query result in excel file

    Hi all,
    How to save query result in excel file from sql*plus tool.
    thank you

    Do you really need an Excel file (binary) or a simple CSV?
    If you just need a CSV then search for DUMP_CSV at http://asktom.oracle.com or at this forum
    If you need formatting and/or multiple worksheets then you can use free tools like
    https://xml-spreadsheet.samplecode.oracle.com/ or https://exceldocumenttype.samplecode.oracle.com/
    Regards
    Marcus

  • Send query results to a file using Toad

    Hello,
    I have a select statement that generates xml rows, and I need to send the results to a file. I am using TOAD VI. The rows generate ok but when I right click and choose the save as option all I end up with is an empty file.
    Is there a way I can just send the results directly to a file instead of to the screen?
    Thanks.

    user11293056 wrote:
    Would you happen to know of a website that shows how to create an xml file using SQL*Plus?
    Thanks.A search of asktom.oracle.com for the following phrase found a couple interesting pages:
    table(xmlsequence(cursor
    On such page is this one:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:1074646661177911::::P11_QUESTION_ID:4061080732051
    As an experiment, you might take a look at the output of the following (replace SELECT * FROM MY_TABLE_HERE with your SQL statement):
    SELECT
    FROM
      TABLE(XMLSEQUENCE(CURSOR(
        SELECT
        FROM
          MY_TABLE_HERE
       )));Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Saving query result to a file

    Hi,
    I have a sql*developer version 1.5 but i am getting a problem while saving query result to a file. When i click on "script output "-> "file icon" nothing is showing.
    Can anyboby guide me whether its a bug or some other settings are required.
    I have oracle 10.2.0.3 working on linux.
    Thanks & regards
    Girish

    I am getting the same thing and as far as I know it is a bug.
    As a workaround, you can either copy the contents of the script output or run the query as a statement (F9) instead of as a script (F5) and export the query results from the results tab.

  • Is it possible to export the graphical display of a Query Result to .xls ?

    Hi Guru's
    Is it possible to export the graphical display of a Query Result to .xls ?
    Please give me some assistance
    Points will be assigned
    Thanks and Regards
    Srikanth

    Hi Srikanth,
    Checked it....I am able to save that as a .XLS in the above mentioned process.
    Try it again.
    Regards,
    Ram.

  • Saving query results to text file

    Hi experts,
    I would like to save a query results to text file.
    The query has desined to the correct structure and I wish the query results will be saved automaticly to text file every time the query is running.
    The query should cintain some sql code that will save the query to text file instead of show the query results.
    What function of SQL should I add to query to achieve that goal. (The query is a long one).
    Thanks in advance,
    Joseph

    If you are talking about Query Manager, it is not difficult to do.  No matter how long your query coding is, just go to the start point of your query.  Then press CtrlShiftEnd to select all the TEXTs.  CtrlC and CtrlV will copy the text (query codes) to text file easily.
    Thanks,
    Gordon

  • Write Query Results into a text file

    Hello All,
    In SAP B1 Query Generator I'm trying to write the results of a query into a text file (.txt). I've tryed with queryout but it doesn't work.
    What I want is something like this:
    SELECT * FROM TABLE queryout "C:/textfile.txt"
    Any sugestions?
    Thanks in advance,
    Miguel Barbosa

    Hello All,
    Since yesterday and due to your help, I've found how to solve my problem.
    This post is only to share with you and with the others users of Expert Forums how to Write the results of an SQL Query in SAP Business One to a Text File without making it by exportation.
    Requested Text File by customer:
    Document type in R/3 If Invoice -- 'Z100' - Position 1 to 4 - 4 characters
    Supplier Code -- dbo.Table.CardCode -- Position 5 to 15 - 10 characters
    Item Code -- dbo.Table.ItemCode -- Position 11 to 25 - 14 characters
    Client Code -- dbo.Table.CardCode -- Position 26 to 36 - 10 characters
    Client Name -- dbo.Table.CardName -- Posiiton 37 to 100 - 63 characters
    Fixed Blank Field -- ' ' -- Position 101 to 120 - 19 blank spaces
    Quantity -- dbo.Table.Quantity -- Position 121 to 140 -- 19 characters
    Unit Price -- dbo.Table.PriceBefDi -- Position 141 to 160 -- 19 characters
    If Invoice Fixed identifier -- 'Z01' -- Position 161 to 163 -- 3 characters
    Fixed Blank Field -- ' ' -- Position 164 to 220 -- 56 characters
    Document Date -- dbo.Table.DocDate -- Position 221 to 229 - 8 characters
    Delivery Date -- dbo.Table.ActDelDate -- Position 230 to 238 - 8 characters
    Sales Order Number - dbo.Table.DocNum -- Position 239 to 260 - 21 characters
    Delivery Number - dbo.Table.DocNum -- Position 261 to 282 - 21 characters
    Follows the code:
    EXEC master..xp_cmdshell'bcp
    SELECT DISTINCT
    ''Z100''
    + ''ZP00002091''
    + IsNull(Convert(nVarChar(44), Cast(T0.DocNum As Numeric(38, 0))), '''')
    + ''PTAP''
    + ''          ''
    + ((LTRIM(RTRIM(T1.U_NumConc)))) + SPACE(10-LEN(LTRIM(RTRIM(T1.U_NumConc)))) + ((LTRIM(RTRIM(T3.BaseRef)))) + SPACE(10-LEN(LTRIM(RTRIM(T3.BaseRef))))
    + ''                    ''
    + ''Z02''
    + CONVERT(varchar(10), T1.ActDelDate, 112)
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''    ''
    + IsNull(Convert(nVarChar(44), Cast(T1.BaseRef As Numeric(38, 0))), '''')
    + ((LTRIM(RTRIM(T1.ItemCode)))) + SPACE(18-LEN(LTRIM(RTRIM(T1.ItemCode))))
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.Quantity AS NUMERIC (38,3))))),'' '',''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,3),T1.Quantity))))),''.'','''')
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.PriceBefDi AS NUMERIC (38,2))))),'' '', ''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,2),T1.PriceBefDi))))) ,''.'','''')
    + ''ZPHA''
    + ''          ''
    + ''  ''
    + ''                         ''
    + ((LTRIM(RTRIM(T4.CardName)))) + SPACE(69-LEN(LTRIM(RTRIM(T4.CardName))))
    + ''                        ''
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''               ''
    FROM
    JFOTST.dbo.OINV T0
    INNER JOIN JFOTST.dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN JFOTST.dbo.ODLN T2 ON T2.DocNum=T1.BaseRef
    INNER JOIN JFOTST.dbo.DLN1 T3 ON T3.DocEntry=T2.DocEntry
    INNER JOIN JFOTST.dbo.OCRD T4 ON T1.U_NumConc=T4.AddId
    WHERE T0.CardCode=''C52''
    queryout "c:\text1.txt" -c -T -x'
    Note that in this code everytime you need to use the symbol ' you have to doble it like ''Fixed Text''.
    Be aware that there is one UDF so if you try to make this query run in your SB1 you will have to create a UDF called U_NumConc in the document lines.
    Database usage:
    JFOTST.dbo.OINV T0
    JFOTST.dbo - Database Name.
    OINV - Table
    T0  - Alias
    For any doubts I'll be available to help.
    Once again thank you very much for all your help.
    Together we are stronger!
    Kind Regards,
    Miguel Barbosa
    Edited by: Miguel Barbosa on Aug 18, 2009 12:09 PM
    Edited by: Miguel Barbosa on Aug 18, 2009 12:10 PM

  • Procedure to write Oracle Query Result to Excel file?

    Hi All,
    I have a requirement to write a procedure which will write the result of a Query (select statement) to a Excel file.
    I use a third party tool to do so but it fails when the query fetches more than 65000 records!
    Can someone suggest me a procedure ( may be written in PL/SQL ) which can be used to achieve this task?
    If there is a procedure available readily, can you please share it with me?
    Thanks in advance
    Himanshu Dabir

    There is a ready procedure (actually PL/SQL blocks by Tom Kyte) available at
    http://www.quest-pipelines.com/newsletter-v5/0704_C.htm
    but it also suffers from Microsofts limitation of 65536 rows per sheet.

  • How to dump a query on a XLS file?

    I´m working in a stored procedure on that i can send a dinamic query and it return me the result into a xls file.
    I´ve found the way to generate that xls file from Pl/sql, but now I need be able to assing each field of each row into his corresponding cell. For this I need to put each field of each row in a variable and then work on it.
    For generate xls file, I´ve created a datatype by following the indications of Jasson Bennet´s blog.
    http://radio-weblogs.com/0137094/2006/10/26.html
    In the example, values are assigned directly to the cells. But it not is valid for me because I dont know what will be these...
    I think that if you want see the blog, you´ll can understand better what I´m refering...
    Thanks for your time...

    Strange requirement, you don't know the query, the columns and the number of rows you get, but you know that you want the value of the second column of the second row :)
    But try this
    declare
      t_c integer;
      t_r integer;
      t_v varchar2(100);
    begin
      t_c := dbms_sql.open_cursor;
      dbms_sql.parse( t_c, q''select 'Roy' name, 'sales' deptno, 25 age from dual
    union all select 'Sara', 'HHRR', 30 from dual
    union all select 'Mike', 'finances', 35 from dual'', dbms_sql.native );
      dbms_sql.define_column( t_c, 2, t_v, 100 );
      t_r := dbms_sql.execute( t_c );
      t_r := dbms_sql.fetch_rows( t_c );
      t_r := dbms_sql.fetch_rows( t_c );
      dbms_sql.column_value( t_c, 2, t_v );
      dbms_sql.close_cursor( t_c );
      dbms_output.put_line( t_v );
    end;
    /

  • Export query results into .csv file?

    Hello I have a T-SQL script that gets row counts for a specified date range and then needs to loop (by incrementing +1 day to get the next day's counts) for a large date range.  I'm aiming to output & append each query results day counts
    into a .csv file via a SQL Agent job since this will take quite a while to complete.
    Would using the following as an example template...
    INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\;HDR=YES;FMT=Delimited','SELECT * FROM [FileName.csv]')
    SELECT Field1, Field2, Field3
    FROM DatabaseName
    ...be the method or something else?
    If this is good to use I've tried running this but get the following error:
    Msg 7357, Level 16, State 2, Line 76
    Cannot process the object "SELECT * FROM [FileName.csv]". The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions
    on that object.
    Thanks in advance.

    Hi Techresearch7777777,
    The error in your post says that the file FileName.csv has to be created with the column names in the first row. Like:
    Field1,Field2,Field3
    Either you can create a schema.ini file under the same folder:
     [FileName.csv]
     Format=CSVDelimited
     ColNameHeader=False
     Col1=Field1 [DataType]
     Col2=Field2 [DataType]
     Col3=Field3 [DataType]
    For the [DataType],you can reference
    Schema.ini File (Text File Driver)
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Query result to ASCII file output

    Seems like there SHOULD be some rediculously simple solution
    to this - but I sure haven't found it yet! I have a query which
    produces the a varying number of columns (based on a multi-select
    cfselect) which I need to output to a comma delimited ASCII (.TXT
    or .DAT or .CSV file). I have all the steps worked out when the
    number of columns and their names are known, but I need to make
    this variable. First choice would be to be able to just "DUMP" the
    query result into a text file. CFDUMP can send results to a text
    file, but NOT in comma delimited format, and with all kinds of info
    besides just the basic data. (NOT good!) Second choice, since the
    "append to text file" uses an output property that expects a comma
    delimited string variable would be to use CFLOOP to loop thru the
    rows in the query and put them (a row at a time) into a variable,
    then use that variable for the file append. Problem is I can't find
    a way to just say "send *ALL* to the string variable. Every example
    I have been able to find includes specifying the column NAMES when
    doing anything with a row in the query result!!! Short of a brute
    force series of if/then statements that specify EACH POSSIBILITY
    (in this case 60 - 75 of them, and the number WILL GROW!) I haven't
    been able to find a solution. There's GOTTA BE A WAY!!!!! :)

    auntiealias
    > I tried that, but as far as I could figure you still
    have to have a specific column name
    Look at the udf more closely. If you read the documentation
    it states all of the parameters are optional, except the query. So
    if you do not supply column names, the function will use the
    columnList variable to determine the names of the columns in the
    query. If you look at the actual code, notice it uses array
    notation to extract the values (not evaluate) .
    ... (code to create query) ...
    <!--- pass in the query object only ---->
    <cfset test = QueryToCSV2( data )>
    http://cflib.org/index.cfm?event=page.udfbyid&udfid=1197
    > I have a cfselect with multiple set to "yes" and the
    selections are "which columns of
    > data do you want to see?"
    Hopefully you are not using the raw form value directly in
    your sql, because that is a sql injection attack just waiting to
    happen.

Maybe you are looking for

  • Integration between SRM-Confirmation and MM-FI Closing in R/3

    We are currently using SRM 5.0 through the Classic-Extended Scenario. For some of our Company Codes in R/3, Monthly closing is performed before the actual end of the month ( generally on the 27th or 28th day of the month) by blocking posting in R/3-F

  • BD Question. How to tell if subVI input is wired?

    Greetings, Inside a subVI, I'm looking for a method to determine if an input is wired from a higher-level VI, or if I'm working with data that was stored in the input control as default data. Any ideas?

  • IPhoto Trash can is not getting empty.

    I am trying to use iPhoto trash can method.  just click on emtpy trash can.  But it is not working. Recently, I cleaned up my library, and deleted about 13k photos.  When I click empty, shows status bar, and it appears stucked.  I need to force out i

  • Function Module used in SE09 Transaction.

    Hi, In SE09 Transaction, When we click on the object included in the work bench Transport request, Object will be opened by the respective Transaction. For eg, If we click on a program included in the Transport request, Program wll be opened in SE38

  • SQL Practice

    Hello everyone. I have been using SQL for almost a year now and am currently studying for my 70-461 exam. I have the Microsoft training kit book, have read, highlighted, and done most of the exercises, however the best way for me to learn is just con