SET
Translation reference to convert SQL Server SET statement to Snowflake
Description
Sets the specified local variable, previously created by using the DECLARE @local_variable statement, to the specified value. For more information for SQL Server SET, check here.
There are four SET cases that are the following:
SET
{ @local_variable
[ . { property_name | field_name } ] = { expression | udt_name { . | :: } method_name }
}
|
{ @SQLCLR_local_variable.mutator_method
}
|
{ @local_variable
{+= | -= | *= | /= | %= | &= | ^= | |= } expression
}
|
{ @cursor_variable =
{ @cursor_variable | cursor_name
| { CURSOR [ FORWARD_ONLY | SCROLL ]
[ STATIC | KEYSET | DYNAMIC | FAST_FORWARD ]
[ READ_ONLY | SCROLL_LOCKS | OPTIMISTIC ]
[ TYPE_WARNING ]
FOR select_statement
[ FOR { READ ONLY | UPDATE [ OF column_name [ ,...n ] ] } ]
}
}
}Sample Source Patterns
SQL Server
Snowflake Scripting
SET statement outside routines (functions and procedures)
Unlike SQL Server, Snowflake does not support executing isolated statements like SET 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 after a DECLARE STATEMENT.
SQL Server
Snowflake Scripting
If there is a scenario with only SET statements, the DECLARE block is not necessary. Probably this scenario will produce runtime errors if there is an attempt of setting a value to a variable that is not declared.
SQL Server
Snowflake Scripting
Known Issues
1. SET of a local variable with property name
This type of set is not currently supported by Snowflake scripting.
2. SET of a local variable with mutator method
This type of set is not currently supported by Snowflake scripting.
Related EWIs
SSC-EWI-TS0037: Snowflake Scripting Cursors are non-scrollable.
SSC-EWI-0073: Pending Functional Equivalence Review.
Last updated