All Forums Database
smithaa 23 posts Joined 08/09
16 Apr 2010
calling bteq in unix shell script

How to call bteq in unix shell script?

srinivasa meka 10 posts Joined 01/10
16 Apr 2010

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.

smithaa 23 posts Joined 08/09
19 Apr 2010

Thanks srinivasa ...

srinivasa meka 10 posts Joined 01/10
21 Apr 2010

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.

srinivasa meka 10 posts Joined 01/10
21 Apr 2010

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

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

bhanu01 3 posts Joined 02/16
08 Mar 2016

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
 

ranganna 4 posts Joined 10/15
09 Mar 2016

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

yuvaevergreen 93 posts Joined 07/09
11 Mar 2016

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.

You must sign in to leave a comment.