Automate my Teradata queries


Automate my Teradata queries


I have some teradata codes which I want to automate. It should be done in a way that they can execute themselves on a specific date/time of a month. 

Any help will be appreciated.



Tags (1)
Senior Supporter

Re: Automate my Teradata queries

Calling the SQLs from BTEQ and schedule the BTEQ calls with a scheduler, cron etc....


Re: Automate my Teradata queries

Hey, thank for replying. Can you please elaborate a bit?


Re: Automate my Teradata queries

Hi Parteek,

You need to put your SQL code inside Bteq as said by Ulrich. BTEQ is a Teradata sql processing tool, if you need further information about Bteq, do let me know. if you have an idea of Bteq then put your code in Bteq and use some job schedular to automate the Bteq script calls.

There are numerous job schedulars available in market, a list is available at

You can also use linux feature as given at below URL


Re: Automate my Teradata queries

You can read the following blog to have a basic idea of Bteq


Re: Automate my Teradata queries

Hi Prateek,

You can put your modularized codes according to the way they can execute themselves with all the logics, conditional and branching required with date/time inside a stored procedure. If it is just one one chunk of function or subject area, then you can put in one proc. If you have many procs and inter dependencies, then you can use schedulers. The best practice is to have audit log and restartability.

There are so many schedulers available.

Thanks and regards,



Re: Automate my Teradata queries

Thanks guys, this was helpfull. :)


Re: Automate my Teradata queries

Dear all, 

I have the same enquiry: I want to schedule my Teradata query to run every day at a given time but I am not sure I have understood the approach with BTEQ... Could you please elaborate more about this solution? An example would be more than appreciated. 

Best regards. 


Re: Automate my Teradata queries

Say if I need to refresh the content of my table at 1:00 AM every friday,

I will use the following btq script (which includes insert query) and unix scheduler like cron:

btq script example :

.logon <teradata serverName>/<UserId>,<Password>;;

drop table DB.<Table>;

create table DB.<Table>

(store_Id smallint);

.IMPORT DATA FILE=/<path to file>/in.dat



USING  storeId (smallint)

insert into DB.<Table>(store_Id) values (:storeId)





CRON Example :

00 1 * * 5 sh  /<path to your script>/ 1>>/<path to log>/Script.log 2>&1

00- Minutes

1 -  Hour

* - Every

5 - 5th day of week (Starting from Monday so in this case Friday)