pentaho data integration excel file outputs - pentaho

using the Pentaho ETL tool I am trying to get an SQL query result dumped into an excel file output. I have created an excel file and saved it but the transformation executes but does not update the excel file. I am trying to insert select * from table A into the excel file.
The connection to the database is fine as I have other transformations.
The two steps are execute SQL script which I have tested in isolation and works, the second is the Microsoft excel output which is not working.
Any suggestions?

Use Table input instead of Execute SQL script. Execute SQL script doesn't give output to next steps

Related

Is there really no easy way to add an export statement (output to .csv) in SQL Server?

I have worked in SAS for much of my career and always found it easy to write a dataset out to csv using a proc export. I now am working in SQL Server and am not finding any similar functionality. Everything I find on the web refers to copy/paste the data into excel or using an export wizard. I don't like those options as the end goal is to automate this query and have the data output where it can be utilized by other programs. Is there any code based way to achieve this?
Are you using SSMS? CTRL-T then execute your query, you'll get a text (csv) result. Alternatively, Query -> Results to -> Results to Text. Alternatively, you can right click the results grid and select Save Results As
For automation, you can use SQL Server Agent to schedule a job the writes the output of a query to a file.

SQL Server Manager: Loop and Save Files as csv

I just started working with MS SQL Server Management Studio to run a repetitive task of:
Change the source table in the FROM section
Execute the query
Save the file as csv that can be opened in grid form in MS Excel
I know this is far-fetch, but is it possible for me to write a query in a form of:
list = {a,b,...,n}
FOR i = 1 to n
SELECT *
FROM [Server].[list{i}] as Table
WHERE *conditions*
SAVE AS list{i}.csv
NEXT i
Thanks!
Just make sure you get yourself a read-only user so you can't drop tables or delete data or anything.
There are tons of examples and tutorials for using Excel ODBC mssql like these:
https://www.youtube.com/watch?v=joi2HTh45YQ

How to generate SQL results to Excel sheet (Oracle)

I am using SQL developer. I need to export the SQL result set to Excel sheet. I know how to export it by manually.
Currently I am using a batch file. Which in turn run's multiple SQL script files. At the end there is a 1 SQL script which contains multiple SQL select statements. Now I need to export these result to excel sheet while running batch file itself.
Batch file Name: Mytest.SQL it contain multiple script files as below.
##test1.sql;
##test2.sql;
##test3.sql;
##test4.sql;
The last script test4.sql contains multiple select statements, which needs to be exported into multiple excels. Please suggest any solution.
Months ago I have found this solution. A ready to use package to unload query result into xlsx file, also with formating. Here is the link. There is also a description how to use the package.
pl/sql package to unload as xlsx
Hope this helps.
I used to do this VB-script, ie I run queries from Excel:
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set ThisWorkbook.OraDatabase = OraSession.OpenDatabase(sDB$, sUSERID$, 0&)
Set OraDynaSet = ThisWorkbook.OraDatabase.CreateDynaset(QueryText, 0&)
You can in this macro calls a script and write cycle data in Excel
Do you need a specific xls file or a csv file?
If you want a csv you can spool a file with sql.
For xls files, you can't do it easily, you'll probably have to go through another programming langage like java or c# or whatever with a specific library to build your report (e.g. for Java Apache POI).

creating batch file to run sql query in sql developer and store result in excel sheet

I am creating a batch file that will be executed daily at a specific time. The batch file will execute a .sql file. The .sql contains a complex select statement. I have created the sql file using Sql Developer. Also the output of the sql must be stored in an excel sheet with name as todays date.
I have read posts related to batch file to run the sql script but have not found clear answers. I am completely new to batch files.
Thanks
try to use bcp command http://sqlfool.com/2008/12/bcp-basics/ with queryout option

BCP utility to create a format file, to import Excel data to SQL Server 2008 for BULK insertion

Am trying to import Excel 2003 data into SQL table for SQL Server 2008.
Tried to add a linked server but have met with little success.
Now am trying to check if there's a way to use the BCP utility to do a BULK insert or BULK operation with OPENROWSET, using a format file to get the Excel mapping.
First of all, how can I create a format file for a table, that has differently named columns than the Excel spreadsheet colums?
Next, how to use this format file to import data from say a file at: C:\Folder1\Excel1.xsl
into table Table1 ?
Thank you.
There's some examples here that demonstrate what the data file should look like (csv) and what the format file should look like. Unless you need to do this lots I'd just hand-craft the format file, save the excel data to csv, then try using bcp or OPENROWSET.
The format file specifies the column names for the destination. The data file doesn't have column headings so you don't need to worry about the excel (source) cols being different.
If you need to do more mapping etc, then create an SSIS package. You can use the data import wizard to get you started, then save as SSIS package, then edit to your heart's content.
If it's a one-off I'd use the SQL data import size, from right-click on database in mgmt studio. If you just have a few rows to import from excel I typically open a query to Edit Top 200 rows, edit the query to match the columns I have in excel, then copy and paste the rows from excel into SQL mgmt studio. Doesn't handle errors very well, but quick.