How to export the table to a file using BTEQ script in Teradata

EXPORT command in Teradata

Export command is used to store the database information that returned by SQL Select statement in a file. We need to specify the path of the file and its format while export the results from the table in Teradata

Syntax of Export command

BTEQ script to export the table to a file

.LOGON – It is command, which is used to log on to a Teradata Database from BTEQ. We need to specify the teradata server details(tdpid) ,username and password to execute this script.

.EXPORT FILE – It exports the results of the select query into a given file.

.SET SEPARATOR – It inserts the specified string between the columns. Each column content will be separated by ‘|’

Select query – We need to specify the select query to extract the data from the Employee table in Banking_DB. The output will be written into the output.txt file.

.LOGOFF – Ends the current Teradata Database sessions without exiting BTEQ.

.EXIT – Ends the current Terdata Database sessions and exits BTEQ.

We can run this BTEQ script using shell script. Please click the link for more details. Once we have run the BTEQ , the data will be exported into the text file as below


Recommended Articles

Import Excel data into Teradata table