Macro Example – deptdisplay - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
16.20
Published
October 2018
Language
English (United States)
Last Update
2020-02-20
dita:mapPath
kil1527114222313.ditamap
dita:ditavalPath
Audience_PDF_include.ditaval
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

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.