CANCEL
Cancels a running query based on its specific query identifier. The system cancels query execution at the next available pause point, such as between batches of data processing. If the execution of theCANCEL SQL statement fails, you can force the query to terminate immediately by using the KILL SQL statement.
To view active queries and their identifiers, see the sys.queries table.
A CANCEL statement can return these statuses.
| Status Message | Description |
|---|---|
OK | The system successfully terminated the query and restored the resources assigned to its execution. |
ID_NOT_FOUND | The specified query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
NOT_AUTHORIZED | The user does not have UPDATE privilege for the system level to terminate queries. |
NO_CONNECTION | The system lost connection to the database while trying to terminate the query. |
NETWORK_COMMS_ERROR | Cannot communicate across the distributed system to terminate the query. |
INTERNAL_ERROR | The system encountered an unexpected error. |
UPDATE privileges to cancel queries.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
query_id | string | The Universally Unique IDentifier (UUID) of the query to cancel. Must be a valid UUID string enclosed in single quotes. |
9a9eb7e3-3440-4814-871f-7f0584ac2fd8 identifier.
SQL
KILL
Kills a running query identified by its UUID. This SQL statement performs a forceful termination of the query, aborting execution regardless of its current stage. If you want to attempt a more gradual query termination that stops processing at the next pause point, use the CANCEL SQL statement. To view active queries and their identifiers, see the sys.queries table.| Status Message | Description |
|---|---|
OK | The system successfully terminated the query and restored the resources assigned to its execution. |
ID_NOT_FOUND | The provided query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
NOT_AUTHORIZED | The user does not have UPDATE privilege for the system level to terminate queries. |
NO_CONNECTION | The system lost connection to the database while trying to terminate the query. |
NETWORK_COMMS_ERROR | Cannot communicate across the distributed system to terminate the query. |
INTERNAL_ERROR | The system encountered an unexpected error. |
UPDATE privileges to kill queries.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
query_id | String | The UUID of the query to kill. Must be a valid UUID string enclosed in single quotes. |
9a9eb7e3-3440-4814-871f-7f0584ac2fd8.
SQL

