- Categories:
System functions (System Control)
SYSTEM$CANCEL_QUERY¶
Cancels the specified query (or statement) if it is currently active/running.
- See also:
Syntax¶
SYSTEM$CANCEL_QUERY(<query_id>)
Arguments¶
Usage notes¶
A user can cancel their own running SQL operations using this SQL function. Canceling running operations executed by another userrequires a role withone of the following privileges:
OWNERSHIP on the user who executed the operation.
OPERATE or OWNERSHIP on the warehouse that is running the operation (if applicable).
ACCOUNTADMIN role.
For a query run by atask, canceling running operations requires a role withone of the following privileges:
OPERATE or OWNERSHIP on the task that is running the operation.
ACCOUNTADMIN role.
Snowflake query IDs are UUID text strings with hyphens, which are special characters, so the strings must be escaped by using single quotes.
This function is not intended for canceling queries for a particular warehouse or user. Instead, use:
Examples¶
SELECTSYSTEM$CANCEL_QUERY('d5493e36-5e38-48c9-a47c-c476f2111ce5');+-------------------------------------------------------------+| SYSTEM$CANCEL_QUERY('D5493E36-5E38-48C9-A47C-C476F2111CE5') ||-------------------------------------------------------------|| query [d5493e36-5e38-48c9-a47c-c476f2111ce5] terminated. |+-------------------------------------------------------------+