Select query results into excel file
Hi,
I want to put the results of a select query in an csv file(tab separated columns). I dont want to spool command for this . Is there any other method to do this.
Thanks
To get data from oracle to excel to use odbc driver to achive this.
Similar Messages
-
Http 404 error exporting query result into Excel.
Hello. I'm getting an Http 404 The webpage cannot be found" error when trying to export any APEX application's query results into Excel (Application Express 3.2.1.00.10). This was working fine before. Nothing changed with our APEX application. I've been always using I.E. Version 7.0.5730.11 with no problems. I've reset the I.E. defaults and still the problem exists. I've downloaded Mozilla Firefox and the problem does not happen. However, I would like to know why my I.E. still gets this error? Any feedback or suggestions would greatly be appreciated. Thanks for your time.
My EI settings are as follows:
Tools -> Internet Options -> Security
All Three: Internet, Local Intrarnet, and Trusted Sites ... at Custom Level have the following settings:
Downloads:
Automatic prompting for file downloads = Enable
File download = Enable
Font download = Enable
Problem still exists.
Thanks for the help.... any additional feedback or suggestions would greatly be appreciated. Thanks for your time. -
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:
v838hi,
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 -
How to save query result in excel file
Hi all,
How to save query result in excel file from sql*plus tool.
thank youDo 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 -
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
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 DabirThere 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. -
Export result of ssas query result to excel file
Hi All,
I have browsed a SSAS cube. I want to export result of SSAS cube into excel file.
Kindly give your input.
Thanks,
Vivek singhHi,
I do not know whether there is a direct solution but there is an indirect way of doing it. I always follow this method if I ever want to get MDX results into Excel.
1 - Install the DAX Studio (I know you want MDX results, so do not get confused by looking at the word DAX. Continue reading). You can download it from the following location.
http://www.sqlbi.com/tools/dax-studio/
2 - Once you install DAX Studio, Go to the Add-Ins ribbon. Click on DAX Studio.
3 - There is an option "Tabular Server" and there is a drop-down list where you can enter the SSAS (MD CUBE Server) server name. Enter the server name manually. If you have multiple SSAS Databases and if you are interested in a specific SSAS database
enter "Initial Catalog=Your SSAS Database Name" in Additional Options section and Click Connect. You can successfully connect to the SSAS Server now.
Here are the details described so far in pictorial representation.
4 - Enter your MDX manually and execute the code via DAX studio and you will get your results right-away in Excel.
Now, isn't that an elegant way of getting MDX results into Excel :) ? Besides Excel's Pivot Table option, I do not know whether there are any alternate solutions to this but wait for other Pros' comments as well.
Best regards...
Chandima Lakmal Fonseka -
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 -
Saving sql query result as excel file in different spreadsheets
Hi,
I have exported the output of sql into excel sheet as follow:
SET LINESIZE 80
SET PAGESIZE 0
SET FEEDBACK OFF
SET SPOOL ON
SET TERMOUT OFF
SPOOL current_employees.csv
SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
set colsep ,
SELECT * FROM sales;
SPOOL OFF
But my question is how can I export SQL output in multiple excel spredsheets?
Is there anything by which I can switch my spreadsheets through the above SQL script?
Regards,
AshishHi,
I have exported the output of sql into excel sheet as follow:
SET LINESIZE 80
SET PAGESIZE 0
SET FEEDBACK OFF
SET SPOOL ON
SET TERMOUT OFF
SPOOL current_employees.csv
SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
set colsep ,
SELECT * FROM sales;
SPOOL OFF
But my question is how can I export SQL output in multiple excel spredsheets?
Is there anything by which I can switch my spreadsheets through the above SQL script?
Regards,
Ashish -
Loading Query results into a file/cache
Hi,
We have a Query which returns huge volume of data.
spooling all the records will take a lot of time.
Is there any other way through which we can load the results of this huge query into Oracle's Cache / File
Tables used in the Query are Range hash composite partitioned tables.
But, in the query only a single partition is being used.
Suggest any method to acheive the same.
Thanks,
Kris.Alex Nuijten wrote:
.... Blu, you're not suggesting that OP use the database what it's good for, are you?.... But then OP would loose database-independence...
:)Ermm.... darn it, you're right, what was I thinking. ;)
Anyway, should there really be a requirement to output the data to a file, then there's nothing wrong with using UTL_FILE...
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_fh UTL_FILE.FILE_TYPE;
3 begin
4 v_fh := UTL_FILE.FOPEN('TEST_DIR','output.txt','w',32767);
5 DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE,'HH24:MI:SS'));
6 FOR i IN (SELECT * FROM large_tbl)
7 LOOP
8 UTL_FILE.PUT_LINE(v_fh,
9 TO_CHAR(i.large_id,'fm999999')||','||
10 i.large_area||','||
11 TO_CHAR(i.large_line,'fm999999')||','||
12 TO_CHAR(i.datelogged,'DD/MM/YYYY')||','||
13 TO_CHAR(i.large_flag,'fm9')||','||
14 '"'||i.large_text||'"');
15 END LOOP;
16 DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE,'HH24:MI:SS'));
17 UTL_FILE.FCLOSE(v_fh);
18* end;
SQL> /
09:01:08
09:05:20
PL/SQL procedure successfully completed.
Elapsed: 00:04:12.47
SQL> select count(*) from largetbl;
COUNT(*)
6637873Over 6.5 million records in 4 minutes 12 seconds, and that's with data formatting. -
Transferring multi-column query result into MS Excel
Hello everybody!
An ultimate novice in Oracle, with some database concepts, is here.
The very first challenge; which I encoutered is that I want to transfer a Select query result, with multiple columns, into MS Excel sheet in a way that each field occupies a separate column in the sheet.
I hope the forum members will show me a simple way to get around the problem.
Thanks in anticipation.
Rabiwhat will happen the query returns too many rows that
Excel cant hold? I faced this problem and divided the
report into "n" numbers based on the number of rows
returned. Is there any internal logic for it in
oracle?Excel is capable of holding 65536 rows of data on a sheet.
Oracle is capable of writing data out to files.
Oracle does not know or care whether the file it is writing is for Excel or any other product, as the file you are likely to be writing is CSV (comma seperate format) which is an open format, not specifically for Excel. If you need to limit the number of rows per CSV file then you will have to code this "business logic" into your code that produces the CSV file from Oracle. -
Procedure to save the output of a query into excel file or flat file
Procedure to save the output of a query into excel file or flat file
I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
I have run the query --
DECLARE @cmd VARCHAR(255)
SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
Exec xp_cmdshell @cmd
error message--
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
NULL
Goel.AmanHello,
-T:
Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
login_id, and password are not required. If
–T is not specified, you need to specify
–U and –P to successfully log in.
-U:
Specifies the login ID used to connect to SQL Server.
Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
-T option (trusted connection) instead of the
user name and password combination
I would suggest you take a look at the following article:
bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
A similar thread regarding this issue:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
Regards,
Elvis Long
TechNet Community Support -
How to output a query results into a text file
How to output a query results into a text file instead of outputing it to the screen..
is there a way for us to write a SQL query which specifies to output the query results to a text file.
Pls let me know how to do it
Thanking u in advance
regards
MuralyMuraly,
If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
SPOOL c:\temp\report.html
SELECT DEPARTMENT_NAME, CITY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000;
SPOOL OFF
SET MARKUP HTML ENTMAP OFF
In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
Alison -
How can I export the query result into access(*.mdb) file?
Dear all:
I want to export the query result displayed in jsp into excel file
and access file. And I have exported the result into excel format successfully, only one line should be added in the head of Jsp:
<%@ page contentType="application/vnd.ms-excel; charset=gb2312" %>
But how can I export it in access(*.mdb) file? I have replaced "excel"
with "access". But it can't achive my goal.
What should I do to achieve my goal?
Thanks!The only reason your Excel export works is that Excel knows how to interpret comma separated values as an input file format. Access has no such beast.
If you absolutely must provide info in an mdb, one solution would be to create an ODBC datasource pointing to an empty mdb, then push data into it using the jdbc:odbc bridge, then make a copy of the file and stream it down to the browser. You may run into some ugly file locking items here - set the ODBC connection so it is not shared, and that might help.
This one is going to be ugly.
I suppose another approach would be to write a simple VB applicatin that uses automation to create an MDB, then stream that file down to the browser from your servlet. That would almost certainly be faster than the ODBC approach.
- K -
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
Erwini dont think you can save as excel file but you can save it as CSV use APD or RSCRM BAPI for this
Maybe you are looking for
-
How to join two DataSource in a single InfoSource
Hello, I have got two datasources which both share the same primary key (Field IDCO) and also have several individual fields. For example: Datasource 1: | IDCO | price | Datasource 2: | IDCO | amount | Now I would like to join both datasources into a
-
Reading in a text file to GUI for later analysis
Good Morning any and everyone, I'm trying to get a piece of code working to read in a text file and it isn't working very well. The code has been seriously crunched together from a multitude of sources so I suspect that the error has occurred from th
-
How to find gaps in data?
Hi! I have the following problem. Data: range_id actual_nr AAA 001AAA AAA 002AAA AAA 003AAA AAA 006AAA AAA 007AAA AAA 009AAA BBB 001BBB BBB 002BBB etc. I have to get report in the following form from to nr_of_rows 001AAA 003AAA 3 006AAA 007AAA 2 009A
-
How to Measure frequency of less than 300 Hz
Is it possible to measure frequency without a counter module? All I have is a cDAQ with 9205, 9221 and 9263 modules.
-
CC team account, can this be used remotely? 1 Pennsylvania and 1 NYC person?
I haven't found anything regarding this yet, but myself and another are considering the CC team account, and it seems like the 80GB storage and 2 phone calls aren't a big hit necessarily so we are apprehensive. But, it might be worth it if you can w