Tearadata Query and Result using Export Utility

Tools & Utilities
Enthusiast

Tearadata Query and Result using Export Utility

Hi,
I want to export the teradata queries and their output into a text file.
For doing so I am using the following commands:
.EXPORT FILE=filename
.SET WIDTH 3000
.SET TITLEDASHES OFF;
SELECT col1 ,col2 from T1
WHERE id='Z101';

.EXPORT RESET;
.LOGOFF
.EXIT
EOF

But the above query fetches the data in the file (filename) as:
col1 col2
v1 v2
... ...
But I need the output in the file in this format:
SELECT col1 ,col2 from T1
WHERE id='Z101';

col1 col2
v1 v2
... ...

Solutions to this problem will be appreciated.
Thanks in advance
7 REPLIES
Enthusiast

Re: Tearadata Query and Result using Export Utility

Hi,
Within your file, make 2 statements. First one will be:
SELECT 'SELECT ......... FROM ...... WHERE ...';
Second statement will be the actual SELECT statement.
Please note that to print a single quote, you will need to give 3 single quotes.
Enthusiast

Re: Tearadata Query and Result using Export Utility

Hi Arun,
What you have suggested is very much correct.
But is there any way we can suppress the query header,I mean:
When I write SELECT 'SELECT col1 from Table1;' ;
I get two lines of output:

SELECT 'SELECT..
----------------------
SELECT col1 from Table1;

But is there any way to suppress the 1st line.
I don't want this line to be present in the output file after exporting.What I want is only the query:
SELECT col1 from Table1;
Enthusiast

Re: Tearadata Query and Result using Export Utility

Hi,
Please use SELECT '.....' (title '') FROM ...;
the (title '') function will nullify the header and you will get nothing printed in the place of the header. This will solve your problem.
Enthusiast

Re: Tearadata Query and Result using Export Utility

Thanks Arun
Enthusiast

Re: Tearadata Query and Result using Export Utility

Hi,
I am exporting a query spanning across multiple lines to a text file.
The query looks like this:
SELECT ' SELECT col1, col2,..
............................
..........WHERE id=123
AND ....;';

After I export it to a file , I am getting the query in a single line .
Is there any way I can get it output in multiple lines in the output
text file (so that I don't have to scroll across the text file).
Enthusiast

Re: Tearadata Query and Result using Export Utility

If it is a bteq batch script, why not just redirect the output to a file and edit out the "Query Completed" and any other messages you do not want.

Enthusiast

Re: Tearadata Query and Result using Export Utility

Hi,
I would have to agree with jimm on this. One approach for you to achieve this is as follows:

When doing your select, please make sure to print a special character at every location you want a line break (for example ~). Then open the BTEQ exported file using UltraEdit or EditPlus or any other editor and replace all ~ with a line break. This will automatically reformat your entire file to the format you want.
But please note that if this character appears in your data set, then it could really screw up your entire output file so please exercise caution in selecting your special character.
Hope that helps.