DECLARE
Translation reference to convert Transact-SQL DECLARE statement to Snowflake Scripting
Last updated
Translation reference to convert Transact-SQL DECLARE statement to Snowflake Scripting
Last updated
Transact-SQL DECLARE statement allows the creation of variables that can be used in the scope of the batch or a stored procedure. For more information regarding Transact-SQL DECLARE, check .
Variables can be created in different ways. Variables may or may not have a default value and several variables can be declared in the same line.
Notice that Snowflake Scripting does not allow to create more than one variable per line.
Snowflake Scripting
Transact-SQL allows the creation of table variables that can be used as regular tables. Snowflake scripting does not support this, instead, a table can be created and then dropped at the end of the procedure.
Snowflake Scripting
Snowflake Scripting
If there is a scenario with only DECLARE statements, the BEGIN...END block should have a RETURN NULL statement to avoid errors, since this block can't be empty.
Snowflake Scripting
No issues were found.
No related EWIs.
Unlike Transact-SQL, Snowflake does not support executing isolated statements like DECLARE outside routines like functions or procedures. For this scenario, the statement should be encapsulated in an anonymous block, as shown in the following examples. This statement is usually used before a .