Contents Index Variables Connection-level variables

ASA SQL Reference
  SQL Language Elements
    Variables

Local variables


Local variables are declared using the DECLARE statement, which can be used only within a compound statement (that is, bracketed by the BEGIN and END keywords). The variable is initially set as NULL. The value of the variable can be set using the SET statement, or can be assigned using a SELECT statement with an INTO clause.

The syntax of the DECLARE statement is as follows:

DECLARE variable-name data-type

Local variables can be passed as arguments to procedures, as long as the procedure is called from within the compound statement.

Examples 
Standards and compatibility 

For more information on batches and local variable scope, see Variables in Transact-SQL procedures.


Contents Index Variables Connection-level variables