calling bteq in unix shell script

Database
Enthusiast

calling bteq in unix shell script

How to call bteq in unix shell script?
7 REPLIES
Enthusiast

Re: calling bteq in unix shell script

bteq <log_file.log 2>&1
LOGON username, password;
select count(*) from dbname.tablename;
EXIT;
STOP

Put above in a file (t1.sh) and run from command line. Output and log info will be within the same file (log_file.log). I am assuming that your bteq is configured and already working.
Enthusiast

Re: calling bteq in unix shell script

Thanks srinivasa ...
Enthusiast

Re: calling bteq in unix shell script

Correction:
bteq <log_file.log 2>&1
LOGON usename, password;
select count(*) from dbname.tablename;
EXIT;
STOP

Copy and paste messed up a bit, let me try again; not sure if this is related to CMS or website problem.
Enthusiast

Re: calling bteq in unix shell script

bteq= <=<=STOP= 1=>=log_file.log= 2=>&=1

First line, take out "=" from above. Inserted "=" to ovecome web site deletion of characters.

Re: calling bteq in unix shell script

Hi All,

I am new to Teradata.I need help on below

I want to Export Data from a result of an sql query into a file which would be placed in Unix location.

The Data should be exported in a fixed width format.

Should this be done through a BTEQ script and the script should be called from unix.I am little confused .

Could you please help me how this can be done.

Thanks in Advance

Re: calling bteq in unix shell script

Hi Bhanu ,

Please use below bteq script 

/* login in to teradata  */

.logon 192.168.119.128/DBC,dbc;

/* Define default database */

database edurekaassignment;

/* specify the path where you want to export  in your case you need to specify your unix server path */

.export file= D:\rangaalearning\data1.txt     

. set operator '|'; /* specify the delimter in my case delimeter is | */

sel * from Customer_Addr_Stg_fastload;  /*This sql query result will exprot in the text file  */

.export reset;

.logoff;

.exit;

I think above bteq script help for you. If you have questions let me know

Thanks

Ranga

Enthusiast

Re: calling bteq in unix shell script

Use export option of BTEQ to export the data, if the no of records is less. The output file can be directed to the desired location.