orellabac
orellabac

Reputation: 2645

SNOWFLAKE Schedule Task to run just once

I am looking for a way in Snowflake to schedule a task to run JUST ONCE.

Any suggestions? Some CRON expressions allow to specify year but I think that SF tasks do not allow that.

Upvotes: 0

Views: 1273

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175606

A task could run Snowflake Scripting block and the last step could be dropping or pausing it:

CREATE OR REPLACE TASK SchemaName.MyTask
WAREHOUSE = 'COMPUTE_WH'
SCHEDULE = 'USING CRON 0 0 1 1 * UTC'
AS
BEGIN
  -- somecode

  -- remove xor suspend
  DROP TASK SchemaName.MyTask;
  ALTER TASK SchemaName.MyTask SUSPEND;    
END;

Upvotes: 3

Related Questions