Skip to main content
Version: 4

Scheduled Query

The Scheduled Query trigger allows you to automate the execution of SQL queries or tasks on a predefined schedule. It enables you to schedule the execution of SQL statements at specified intervals or times.

This trigger supports a wide range of SQL statements that you can schedule for execution. These include, but are not limited to:

  1. Data Manipulation Language (DML):

    • INSERT: Inserting rows into a table.
    • UPDATE: Updating existing rows in a table.
    • DELETE: Removing rows from a table.
    • MERGE: Combining INSERT and UPDATE operations based on specified conditions.
  2. Data Definition Language (DDL):

    • CREATE TABLE: Creating a new table in the database.
    • ALTER TABLE: Modifying the structure of an existing table (e.g., adding columns).
    • DROP TABLE: Deleting a table and its data from the database.
  3. Data Query Language (DQL):

    • SELECT: Retrieving data from one or more tables.
    • WITH (Common Table Expressions): Defining temporary result sets that can be referenced within the query.
  4. Transaction Control Language (TCL):

    • COMMIT: Finalizing all data changes made in the current transaction.
    • ROLLBACK: Undoing all data changes made in the current transaction.
  5. Other SQL Statements:

    • CREATE VIEW: Creating a virtual table based on the result set of a SELECT statement.
    • CREATE INDEX: Creating an index on a table to improve query performance.
    • GRANT/REVOKE: Managing access privileges to database objects.

Trigger Conditions​

Action condition
Description
The statement to execute

Enter the SQL query or queries that you want to schedule for execution specifying the schedule for when the query should run.


Here's an example of a SQL statement that creates a Scheduled Query to execute a SELECT statement on a daily schedule:

<ch:codesample></ch:codesample>
<label>Statement count</label>Provide the MULTI_STATEMENT_COUNT parameter, which corresponds to the number of SQL statements being submitted.