---
title: STATEMENT_TIMEOUT
description: Set a timeout in seconds after which running SQL statements are canceled with the STATEMENT\_TIMEOUT configuration parameter in Databricks SQL.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/parameters/statement_timeout
---

# STATEMENT\_TIMEOUT

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL

The STATEMENT\_TIMEOUT configuration parameter specifies a timeout duration in seconds. The count starts at the beginning of the SQL statement's execution. Any Databricks SQL statement with a run time exceeding the value is timed out.

You can set this parameter at three scopes:

* **Session**: Applies to statements in the current session. Use the [SET statement](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set.md).
* **Warehouse**: Applies to all statements that run on a specific SQL warehouse. Use the [SQL warehouses API](https://docs.databricks.com/api/warehouses/v1/warehouse).
* **Workspace**: Applies to all SQL warehouses in the workspace. Use workspace admin settings or the [Set SQL configuration parameters API](https://docs.databricks.com/api/warehouses/v1/set-workspace-warehouse-config).

## Setting

Set a timeout value in seconds between 0 and 172800 seconds (2 days). Any Databricks SQL statement that has an execution time exceeding the set value is halted.

## System default

The system default is 172800 seconds (2 days).

## Precedence

When the timeout is set at more than one scope, the first non-null value in the following order applies:

1. Session
2. Warehouse
3. Workspace

If the timeout is not set at any scope, the [system default](https://docs.databricks.com/aws/en/sql/language-manual/parameters/statement_timeout.md#system-default) applies.

## Examples

The following example sets a session-level timeout and then resets it.

```sql
-- Set a session-level timeout
> SET STATEMENT_TIMEOUT = 86400;
> SELECT * FROM DIAMONDS;

-- Reset the timeout duration
> RESET STATEMENT_TIMEOUT;
> SELECT * FROM DIAMONDS;
```

To set a workspace-level timeout, go to the workspace admin settings, click **Compute**, then click **Manage** next to **SQL warehouses**. In the **SQL Configuration Parameters** setting, add a configuration parameter where the timeout value is in seconds.

```sql
-- Set a workspace-level timeout
> STATEMENT_TIMEOUT 86400
```

## <a id="warehouse-level-timeout" />Notes

For information about setting, removing, and checking a warehouse-level timeout, see [Statement timeout](https://docs.databricks.com/aws/en/compute/sql-warehouse/warehouse-behavior.md#statement-timeout).

## Related

* [RESET](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-reset.md)
* [SET statement](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set.md)
* [Configure SQL parameters](https://docs.databricks.com/aws/en/admin/sql/index.md#params)
* [SQL warehouses API](https://docs.databricks.com/api/workspace/warehouses)
