13 May 2018        Add to Favorites   Report

Create Macro in Teradata

Macro is a set of SQL statements which are stored and executed by calling the Macro name. The definition of Macros is stored in Data Dictionary. Users only need EXEC privilege to execute the Macro. Users don't need separate privileges on the database objects used inside the Macro. 

  • Macro statements are executed as a single transaction. If one of the SQL statements in Macro fails, then all the statements are rolled back
  • Macros can accept parameters
  • Macros can contain DDL statements, but that should be the last statement in Macro


CREATE MACRO macroname(parameter1, parameter2,..) (

<sql statements>



CREATE MACRO Get_Emp_Salary(EmployeeNo INTEGER) AS (

SELECT * FROM Salary WHERE EmployeeNo = :EmployeeNo;


Read great educational content like this and a lot more ! Create my free account now 🎁