BTEQ:saving output in multiple file

Tools & Utilities
vc
Enthusiast

BTEQ:saving output in multiple file

Hello All.

I am writing a bteq which is saving the output in the One file.Bteq has 3 different queries.

I need to save outout of all the three queries in three seprate files using one BTEQ.is it possible?

Also can we call bteq file within a bteq?

Regards 

Vc

1 REPLY
Teradata Employee

Re: BTEQ:saving output in multiple file

We would use the .export and .run statements for this type of functionality:

 

 BTEQ -- Enter your SQL request or BTEQ command:
.os cat /tmp/input.sql

.os cat /tmp/input.sql
.export report file=/tmp/out1.txt
select count(*) from sar_ru_t;


.export report file=/tmp/out2.txt
select count(*) from sar_ru_t;

.export report file=/tmp/out3.txt
select count(*) from sar_ru_t;

.export reset
 BTEQ -- Enter your SQL request or BTEQ command:

.run file = /tmp/input.sql

.run file = /tmp/input.sql
 BTEQ -- Enter your SQL request or BTEQ command:

.export report file=/tmp/out1.txt
 *** To reset export, type .EXPORT RESET
 BTEQ -- Enter your SQL request or BTEQ command:

select count(*) from sar_ru_t;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.


 BTEQ -- Enter your SQL request or BTEQ command:

 

.export report file=/tmp/out2.txt
 *** To reset export, type .EXPORT RESET
 BTEQ -- Enter your SQL request or BTEQ command:

select count(*) from sar_ru_t;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.


 BTEQ -- Enter your SQL request or BTEQ command:


.export report file=/tmp/out3.txt
 *** To reset export, type .EXPORT RESET
 BTEQ -- Enter your SQL request or BTEQ command:

select count(*) from sar_ru_t;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.


 BTEQ -- Enter your SQL request or BTEQ command:


.export reset
 *** Output returned to console.
 BTEQ -- Enter your SQL request or BTEQ command:
 *** Encountered EOF on RUN file. Returning to stdin.
 BTEQ -- Enter your SQL request or BTEQ command:

 

Consider using the bteq .help for this type of information:

 

 BTEQ -- Enter your SQL request or BTEQ command:
.help bteq

.help bteq

 BTEQ is a general-purpose utility which enables you to submit
 SQL queries to the Teradata Database; it formats the results and
 returns them to the screen, file, or printer.

 BTEQ Command-line Arguments :

.... <cut for size> ...