Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 12:34 PM
Hi @MarkD how are you?
The `SET` command alone is typically used to change the settings of a session, such as configuration parameters.
To define a variable inside a SQL statement, you can use SET VAR <variablename> = <variablevalue> or SET VARIABLE <variablename> = <variablevalue> to define, as on the example below:
-- Set a SQL variable to a value using SET VAR > SET VAR myvar1 = 5; > VALUES (myvar1); 5 -- Set a SQL variable to 7 using the SET VARIABLE command > SET VARIABLE myvar1 = 7; > VALUES (myvar1); 7
Please relate to the SET VAR documentation for further reference: https://docs.databricks.com/ja/sql/language-manual/sql-ref-syntax-aux-set-variable.html
Take care!