# User-Defined Variables

SingleStore allows users to define session variables to store values and reference these variables in subsequent queries. These user-defined variables are session variables meaning that they exist only during your session and are local in scope to your session.

You can use `SELECT ... INTO` or `SET` to create user defined session variables.

```sql
SELECT ... INTO @user_defined_variable [,...]

```

```sql
SET @user_defined_variable = <expr>
```

For stored procedures and anonymous code blocks, you can use `SELECT ... INTO <var>` to create variables; however, those variables are *locally scoped* variables, not session variables.

## Related Topics

* [Anonymous Code Blocks](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/anonymous-code-blocks.md)
* [Stored Procedures](https://docs.singlestore.com/db/v9.1/developer-resources/procedural-extensions/stored-procedures.md)

## In this section

* [SELECT ... INTO User Defined Variable](https://docs.singlestore.com/db/v9.1/reference/sql-reference/user-defined-variables/select-into-user-defined-variable.md)
* [SET](https://docs.singlestore.com/db/v9.1/reference/sql-reference/user-defined-variables/set.md)

***

Modified at: April 3, 2024

Source: [/db/v9.1/reference/sql-reference/user-defined-variables/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/user-defined-variables/)

(An index of the documentation is available at /llms.txt)
