Snowflake Task creation(Scheduler)

A task can execute a single SQL statement or a call to a stored procedure.Tasks can be combined with table streams for continuous ELT workflows to process recently changed table rows. Streams ensure exactly once semantics for new or changed data in a table. Tasks can also be used independently to generate periodic reports by inserting or merging rows into a report table or perform other periodic work.

To create a new task this is the syntax:

create or replace task <name>
WAREHOUSE = <name of warehouse>
schedule = "using cron <time> <timezone>"
as <SQL>

name: Name of the task

name of warehouse: your warehouse name

time & time zone: Specifies a cron expression and time zone for periodically running the task. Supports a subset of standard cron utility syntax.For a list of time zones, see the list of tz database time zones(in Wikipedia).The cron expression consists of the following fields:

SQL : your query(code) to schedule

For example,

create or replace task Task_Cost
WAREHOUSE = "DATASCHOOL_WH"
schedule = "using cron 00 14 * * * GMT"
as
create or replace view "DS28_Project_Cost" as
select *, datediff(hour,"START_TIME","END_TIME") as "Hour" from snowflake.account_usage.metering_history

Resume/Pause the task:

When the task is created, it is in suspension mode therefore we have to resume the task. To resume it,

Alter Task <name> RESUME/SUSPEMD

Delete the task:

When you are done with the task: you can drop your task:

drop TASK <name> ;

Its very easy to create task in snowflake, If you want to take deep dive into it please read the this documentation: https://docs.snowflake.com/en/sql-reference/sql/create-task.html

Author:
Tulsi Majithia
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab