SET
statementsupportedAccounts, users, sessions, warehousesInitializes the value of a session variable to the result of a SQL expression. To write to a schema variable, use a qualified name (SET schema.name = value or SET database.schema.name = value). An unqualified SET name = value always targets a session variable, even if a schema variable of the same name exists.
Syntax
SET <var> = <expr>
SET ( <var> [ , <var> ... ] ) = ( <expr> [ , <expr> ... ] )
Parameters
| Name | Required | Description |
|---|---|---|
var | Specifies the identifier for the variable to initialize. | |
expr | Specifies the SQL expression for the variable. |
Usage notes
- You can set multiple variables in the same statement.
- If you specify complex expressions, a running virtual warehouse might be required in the session.
- The number of expressions must match the number of variables to initialize.
- The size of string or binary variables is limited to 16 KB.
- The identifier (that is, name) for a SQL variable is limited to 256 characters.
- Variable names such as CURRENT or PUBLIC are reserved for future use by Snowflake and cannot be used.