A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/sql/set below:

Website Navigation


SET | Snowflake Documentation

SET

Initializes the value of a session variable to the result of a SQL expression.

See also:

SHOW VARIABLES , UNSET

Syntax
SET <var> = <expr>

SET ( <var> [ , <var> ... ] )  = ( <expr> [ , <expr> ... ] )

Copy

Parameters
var

Specifies the identifier for the variable to initialize.

expr

Specifies the SQL expression for the variable.

Usage notes Examples

These two examples use constants to set variables:

SET V1 = 10;

SET V2 = 'example';

Copy

This example sets more than one variable at a time:

SET (V1, V2) = (10, 'example');

Copy

This example sets the variable to the value of a non-trivial expression that uses a SQL query:

SET id_threshold = (SELECT COUNT(*)/2 FROM table1);

Copy

The following example shows the result when a SET command evaluates all of the expressions on the right-hand side of the assignment operator before setting the first expression on the left-hand side of the operator. Note that the value of the variable named max is set based on the old value of min, not the new value.

SET (min, max) = (40, 70);

Copy

SET (min, max) = (50, 2 * $min);

SELECT $max;

Copy

+------+
| $MAX |
|------|
|   80 |
+------+

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4