How to Automate Reports in Snowflake

Galaxy Glossary

How do I automate recurring SQL reports in Snowflake?

Use Snowflake Tasks to run SQL reports on a fixed schedule without manual intervention.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why automate reports in Snowflake?

Automation guarantees fresh metrics without copy-paste work, reduces human error, and frees engineering hours. By combining CREATE TASK with cron-like schedules, Snowflake executes your SQL at precise intervals, logs history, and retries on failure.

What is the syntax for CREATE TASK?

CREATE [ OR REPLACE ] TASK task_name
WAREHOUSE = warehouse_name
SCHEDULE = 'USING CRON cron_expr timezone' | 'interval'
COMMENT = 'optional text'
AS
statement;

You can chain tasks with AFTER, enable with ALTER TASK … RESUME, and inspect runs via SHOW TASKS or SHOW TASK HISTORY.

How do I schedule a daily sales report?

Create a summary table first:

CREATE OR REPLACE TABLE DailySales (
report_date DATE,
total_sales NUMBER(12,2)
);

Then create the task:

CREATE OR REPLACE TASK daily_sales_report
WAREHOUSE = analytics_wh
SCHEDULE = 'USING CRON 0 6 * * * America/Los_Angeles'
AS
INSERT INTO DailySales
SELECT CURRENT_DATE, SUM(total_amount)
FROM Orders
WHERE order_date = CURRENT_DATE;

Resume the task so it starts tomorrow:

ALTER TASK daily_sales_report RESUME;

How can I debug failed tasks?

Query SNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY for the last run’s error_message. Check warehouse credit quota, SQL compilation errors, and privileges on referenced objects. Use EXECUTE TASK daily_sales_report for an ad-hoc run.

What are best practices for automated reports?

Use dedicated warehouses sized for report workloads. Filter data incrementally with order_date >= DATEADD(day,-1,CURRENT_DATE) to minimize compute. Store results in partitioned tables and add quality checks inside tasks or downstream alerts.

Why How to Automate Reports in Snowflake is important

How to Automate Reports in Snowflake Example Usage


-- Weekly customer order count per region
CREATE OR REPLACE TASK weekly_customer_orders
  WAREHOUSE = analytics_wh
  SCHEDULE = 'USING CRON 0 2 * * 1 America/New_York'
AS
INSERT INTO Reports.CustomerOrdersWeekly (week_start, region, order_count)
SELECT DATE_TRUNC('week', CURRENT_DATE)   AS week_start,
       c.region,
       COUNT(o.id)                        AS order_count
FROM Customers c
JOIN Orders o ON o.customer_id = c.id
WHERE o.order_date >= DATE_TRUNC('week', CURRENT_DATE)
GROUP BY 1,2;

How to Automate Reports in Snowflake Syntax


CREATE OR REPLACE TASK daily_inventory_report
  WAREHOUSE = analytics_wh
  SCHEDULE = '1 HOUR'
AS
INSERT INTO InventorySnapshots (snapshot_time, product_id, stock)
SELECT CURRENT_TIMESTAMP, id, stock
FROM Products;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I chain multiple tasks?

Yes. Use AFTER task_name in the CREATE TASK statement to build task trees that run sequentially.

How do I pause or drop a task?

Pause with ALTER TASK task_name SUSPEND; and drop with DROP TASK task_name;. Paused tasks retain history but do not consume credits.

Can tasks send email alerts?

Snowflake tasks cannot natively email, but you can CALL a stored procedure that invokes an external function or webhook to your alerting system.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.