Posted: Thu Jul 08, 2010 9:38 am Post subject: Convert output file to Excel sheet
Hi,
We run a SQL query and get an output of LRECL of 100 with a min of 10 records and max of 25 records on daily basis. The output fiel contains 6 columns.
Would you please let me know how to convert this file into an Excel sheet using any of the utilities.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Thu Jul 08, 2010 10:10 am Post subject:
what do you use to run the query? SPUFI, qmf, DSNUTIL?
the db2 unloads have provisions for inserting semi-colons <;> between each column value.
there was a recent topic (use the search function) where kolusu provided a solution,
(or provided a link to a solution).
normally,
create a flatfile,
download as csv (txt)
and then import (or open) to excel sheet.
I understand that there are utilities that can be BOUGHT that will do some or part of this. _________________ Dick Brenholtz
American living in Varel, Germany
You can also place tab characters between each field and save as a .prn file. This can be opened in Excel as well.
I like this approach because datasets can have commas as part of their data. TABs aren't nearly as common.
If the data you are returning contains character columns, you could concatenate your delimiters in the select clause and return a single string.
Example (with commas):
SELECT FIELD_1 || ',' || FIELD_2 || ',' || FIELD_3 FROM TABLE WHERE...
FTP the result to your C: drive and open in Excel. You would need to convert numerics using DIGITS function and dates using CHAR function to convert other types of data to character before concatenation.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Jul 08, 2010 10:48 am Post subject:
ranga_subham,
Try this . X'05' is tab character, Now your unload file is created as tab delimited file. As jim mentioned if you want readable format of data , then you need to have CHAR scalar function for Varchar data and CHAR/DIGITS scalar function for numeric data
Code:
SELECT DB2_COL_1
,CHAR(X'05')
,DB2_COL_2
,CHAR(X'05')
,DB2_COL_3
,CHAR(X'05')
,DB2_COL_4
,CHAR(X'05')
,DB2_COL_5
,CHAR(X'05')
,DB2_COL_6
FROM TABLE
WHERE ...
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum