If you are user of “sqlplus” in Oracle then surely you would glad to know the equivalent tool available in Teradata is; Basic Teradata Query, more famous as BTEQ. Just like sqlplus it is a client tool that communicates with the Teradata Databases. It has its own set of commands that is helpful for setting/formatting the output on the command prompt. This tool is very useful in case of report generation in txt format.

If you want to run some SQL commands than you can open a BTEQ session and log on to it with the following command and run your SQL command at the command prompt.

.logon   dbserver.dbURL.com/username (and mind it you have to press enter)

You would be prompted to enter your password.Enter your password and press enter again.

While running SQL commands after logging into BTEQ, just remember to suffix a semi-colon (‘;’) at the end of each query and yes do not forget to press “enter”. For example to select current date;

SELECT date ;( press enter again)

If you have needs to write a bunch of SQL queries then put the same into a script and execute it from MS DOS or UNIX. Following are the steps to execute your first BTEQ script. 

  1. Open a txt file and save it as MyFirstBTEQ.txt in path where you have the Queryman installed.
  2. Write the following lines into the txt file
    1. .logon server.mycompany.com/username, password;
    2. DATABASE databasename;
    3. SELECT DATE;
    4. .QUIT ERRORCODE ;
  3. Open MS DOS prompt
  4. Go to the path

C:\<Mypath>\NCR

  1. And run the following command

bteq <MyFirstBTEQ.txt> MyFirstBTEQ.log 

  1. The MyFirstBTEQ.log file is the output file. Open it to see the results.
  2. To see the results on the command prompt run the following command

 bteq <MyFirstBTEQ.txt

Our Random Articles

More Links