CREATE TASK lets you schedule and automate SQL jobs directly inside Snowflake.
Snowflake schedules jobs with CREATE TASK. A task stores a SQL statement and a cron or interval schedule. Once enabled, Snowflake executes the task automatically without external orchestration.
CREATE TASK defines timing through a CRON or USING WAREHOUSE clause. You can trigger tasks by time or by dependency on another task, forming DAG-style pipelines.
SCHEDULE or CRON sets run time; WAREHOUSE specifies compute; USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE reserves capacity; AFTER chains tasks; WHEN prevents runs unless a boolean expression is true.
Use our ecommerce schema. The task aggregates yesterday’s orders into a reporting table. Enable the task to start the schedule immediately.
CREATE OR REPLACE TASK daily_order_summary
WAREHOUSE = analytics_wh
SCHEDULE = 'USING CRON 0 3 * * * America/Los_Angeles'
AS
INSERT INTO order_metrics (summary_date, total_orders, total_revenue)
SELECT CURRENT_DATE - 1,
COUNT(*),
SUM(total_amount)
FROM Orders
WHERE order_date = CURRENT_DATE - 1;
ALTER TASK daily_order_summary RESUME;
Create downstream tasks with AFTER. Snowflake guarantees that a child task starts only after its parent finishes successfully, simplifying ETL pipelines.
CREATE OR REPLACE TASK refresh_product_sales
WAREHOUSE = analytics_wh
AFTER daily_order_summary
AS
MERGE INTO product_sales USING (
SELECT product_id, SUM(quantity) AS sold
FROM OrderItems
GROUP BY product_id
) src ON Products.id = src.product_id
WHEN MATCHED THEN UPDATE SET stock = stock - src.sold;
ALTER TASK refresh_product_sales RESUME;
Query ACCOUNT_USAGE.TASK_HISTORY or INFORMATION_SCHEMA.TASK_HISTORY. Look at LAST_FAILED_RUN_TIME and ERROR_MESSAGE to diagnose problems quickly.
Use dedicated, appropriately sized warehouses. Keep SQL logic idempotent. Store results in separate tables to avoid locking source data. Pause tasks during backfills to prevent double processing.
Mis-sized warehouse: A warehouse too small causes long runtimes and task overlap. Fix by setting USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE or choosing a larger warehouse.
Forgot to RESUME: CREATE TASK defaults to SUSPENDED. Enable with ALTER TASK ... RESUME, otherwise the job never runs.
No. The shortest interval is 1 minute. Use external orchestration for faster cadence.
Run ALTER TASK task_name SUSPEND; to pause without dropping.
Snowflake retries once after a system error but not on SQL errors. Build idempotency and error handling into your SQL.
Yes. Omit WAREHOUSE and Snowflake will run the task on a serverless compute pool, billed per second.
Each account supports thousands of tasks. Concurrency is limited only by warehouse size and credit budget.
Use ACCOUNT_USAGE.TASK_HISTORY for 365-day history or INFORMATION_SCHEMA.TASK_HISTORY for 14-day granular events.