Before setting up your scheduled query, do the following:
Select which query you'd like to schedule
Click on the tab containing the query you'd like to schedule.
If the query hasn't been written yet, open a new tab and write out the SQL.
Open scheduler settings
Click on the scheduler icon that appears to the right of your query tabs (show below). Before clicking, make sure the tab containing the query you want to schedule is open.
Before scheduling your query, you'll need to set up the scheduler.
Your query scheduler settings (screenshot at the end) contain four main sections:
- Give your scheduled query a recognizable name. This will help you identify the query if you have multiple scheduled queries.
- By default, the name you've given the query tab will be used.
Set up scheduler interval
- Determine how often you'd like the query to execute.
- Select one of the preset options in the dropdown, or customize your interval.
- For custom intervals, refer to this article and this article if you need help setting up the proper notation.
Set up the query's destination table
- This is just like setting up a destination table for a regular query.
- Give the table a recognizable name, and decide whether you'd like the results to append to or overwrite the table's previous results.
- Decide whether you'd like to receive alerts when the query executes successfully, fails, or both.
Note: When you are scheduling a query that contains variables, the variable will execute as a literal value.
Scheduler Tips & Tricks
- Execute multiple queries in a single scheduler. Just separate each query with a semicolon (;)
- You can schedule queries that Create, Update, and Delete other tables.
- Set Job priority to Batch mode to help in cases when the scheduled query is triggered during high load times (when using Slots). BigQuery's engine will allocate resources at the best time.
- You can select the billing project the query will be executed on while defining another project inside your SQL.