RETURN (Snowflake Scripting) | Snowflake Documentation (original) (raw)

Returns the value of a specified expression.

For more information about returning values, see Returning a value.

Syntax

Where:

_expression_

An expression that evaluates to the value to return.

Usage notes

Examples

This example declares a variable named my_var for use in a Snowflake Scripting anonymous block and then returns the value of the variable:

DECLARE my_var VARCHAR; BEGIN my_var := 'Snowflake'; RETURN my_var; END;

Note: If you use Snowflake CLI, SnowSQL, the Classic Console, or theexecute_stream or execute_string method in Python Connectorcode, use this example instead (see Using Snowflake Scripting in Snowflake CLI, SnowSQL, the Classic Console, and Python Connector):

EXECUTE IMMEDIATE DECLAREmyvarVARCHAR;BEGINmyvar:=′Snowflake′;RETURNmyvar;END;DECLARE my_var VARCHAR; BEGIN my_var := 'Snowflake'; RETURN my_var; END;DECLAREmyvarVARCHAR;BEGINmyvar:=Snowflake;RETURNmyvar;END;;