# DECLARE and SET variables in BigQuery

Here's a part of procedural language that I use quite a lot in BigQuery.

Whether you're looking to run a query based on a multiple values of a particular parameter, finding out the watermark for incremental loading or just doing some testing, you can DECLARE and SET variables you can reuse across your query.

A couple of ways to do it:  
\- we can declare a variable with no type, but we need to provide a default, from which the time will be inferred  
\- a variable can be declared together with the type and choose to assign a value at declaration or later with SET  
\- a sub query can also provide the implicit value and table of a variable

![](https://miro.medium.com/v2/resize:fit:700/0*bFW5nHNmqpI0Zqik align="left")

*Found it useful? Subscribe to my Analytics newsletter at* [*notjustsql.com*](https://notjustsql.com)*.*

---

*Enjoyed this? Here are some related articles you might find useful:*

- [Parameters in BigQuery](https://datawise.dev/parameters-in-bigquery)

