Export to Excel Or XML

Database
Enthusiast

Export to Excel Or XML

Hi,
Can any one tell me is it possible to export the result of query in to Excel sheet or XML. If yes please give me a brief idea. I want this process to be automated, ie if i give the query the results will be exported to excel or xml at a particular location.

Thanks for your help.

Regards
Chinmay Das
1 REPLY
Enthusiast

Re: Export to Excel Or XML

You can export the data as comma separate values (CSV) into .csv file, and excel can open it.

so in bteq

.set titledashes off;
.set width 1000;

.export file = myfile.csv;

* This is for heading in excel
SELECT "COL1,COL2" (TITLE '');

* actual data select
SELECT ( TRIM(col1) || ',' || TRIM(col2) ) (TITLE '')
FROM MyTable
;

.quit;

(You may have to do a little bit more tidying up, I quickly typed it from my memory)

That should give you a file which can be opened in excel.

You must be able to generate XML similarly by concatenating values...

bteq

.set titledashes off;
.set width 1000;

.export file = myfile.xml;

SELECT ' ' (TITLE '');

* actual data select
SELECT ( ' " ) (TITLE '');

SELECT ' ' (TITLE '');