Macro Example – deptdisplay

Basic Teradata Query Reference

brand
Teradata Tools and Utilities
prodname
Basic Teradata Query
vrm_release
16.20
category
Programming Reference
featnum
B035-2414-108K

To create a macro named deptdisplay, for example, that includes the following BTEQ SEPARATOR command and Teradata SQL SELECT statement:

.SET SEPARATOR ' | '
SELECT * FROM department;

enter:

CREATE MACRO deptdisplay AS  
( ECHO '.SET SEPARATOR '' | '' '
;SELECT * FROM department; 
);
When enclosing single quotes within quotes, double the inner quotes so that each inner, single quote becomes two single quotes.

After creating the macro, BTEQ displays:

*** Macro has been created.
*** Total elapsed time was 3 seconds.
Develop more complex macros by placing them in a file and running the file in a BTEQ batch job.