Categories:

System Functions (System Control)



## Arguments¶

task_name

## Usage Notes¶

• Only the task owner (i.e. the role with the OWNERSHIP privilege on the task) or a role with the OPERATE privilege on the task can call this function.

• task_name is a string so it must be enclosed in single quotes:

• Note that the entire name must be enclosed in single quotes, including the database and schema (if the name is fully-qualified), i.e. '<db>.<schema>.<task_name>'.

• If the task name is case-sensitive or includes any special characters or spaces, double quotes are required to process the case/characters. The double quotes must be enclosed within the single quotes, i.e. '"<task_name>"'.

• This function returns a success message before the current run of the specified task is actually cancelled.

• If the current run of the specified task is almost completed, this function might not cancel the run.

• This function only cancels the current run of the specified task. Additional tasks in a DAG that includes this task might also be running. To cancel these runs, you must call this function and specify the name of each additional child task separately.

To check if a task run has been cancelled or completed, or if any child tasks are currently running, query the TASK_HISTORY function.

• To prevent future runs of the task from starting, we recommend first suspending the task (using ALTER TASK … SUSPEND) and then executing this function.

Note that if the task is not suspended when this function is executed, it currently takes several minutes for the Snowflake cloud services to begin scheduling executions of this task again.

## Examples¶

Abort the current run of a task with a case-insensitive name:

SELECT SYSTEM$USER_TASK_CANCEL_ONGOING_EXECUTIONS('mydb.myschema.mytask');  Abort the current run of a task with a case-sensitive name: SELECT SYSTEM$USER_TASK_CANCEL_ONGOING_EXECUTIONS('mydb.myschema."myTask"');