> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exploratory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Variables in SQL

First, define a variable in R script file.

```
cutoff_date <- "\'2016-01-15\'"
```

Note that the ‘\’ (backslash) symbols are used to escape the single quotes, which are required to be used for characters in SQL queries.

Second, load the R script file.

![](https://mintcdn.com/exploratory-inc/t8wulpy3B474-b7T/en/import/images/variable-1.png?fit=max\&auto=format\&n=t8wulpy3B474-b7T\&q=85\&s=f8524f358445854ed51926291bf4e052)

![](https://mintcdn.com/exploratory-inc/t8wulpy3B474-b7T/en/import/images/variable-2.png?fit=max\&auto=format\&n=t8wulpy3B474-b7T\&q=85\&s=0a3927bc0ac677cb7d2741b17013191a)

Finally, you can use @{} to surround a variable name inside the query like below.

```
select *
from airline_2016_01
where fl_date > @{cutoff_date}
```

Here's a [blog post](https://blog.exploratory.io/using-variables-in-sql-query-2740924d9f20#.bdcn5v68x) for more detail.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.