Macro Example – deptdisplay | Basic Teradata Query - Macro Example – deptdisplay - Basic Teradata Query

Basic Teradata® Query Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Basic Teradata Query
Release Number
20.00
Published
October 2023
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
gxl1691484661681.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
psp1479308573013
Product Category
Teradata Tools and Utilities

To create a macro named deptdisplay, for example, that includes the following BTEQ SEPARATOR command and 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.