---
title: SQL task for jobs
description: Configure a SQL task in a Lakeflow Job to run a Databricks SQL query, alert, or SQL file on a serverless or pro SQL warehouse.
canonical_url: https://docs.databricks.com/aws/en/jobs/tasks/sql
---

# SQL task for jobs

Use the SQL task type to configure a SQL query, alert, or SQL file.

The **SQL** task requires Databricks SQL and a [serverless or pro SQL warehouse](https://docs.databricks.com/aws/en/compute/sql-warehouse/warehouse-types.md).

## Requirements

* You must have your SQL asset in a location accessible by the user configuring the job.

## Configure a SQL task

> [!NOTE]
>
> The jobs UI displays options dynamically based on other configured settings.

To begin the flow to configure a `SQL` task:

1. Navigate to the **Tasks** tab in the Jobs UI.
2. In the **Type** drop-down menu, select `SQL`.

## Configure the SQL task type

In the **SQL task** drop-down menu, select a SQL task type using one of the following options.

### Query

Select a **SQL query** to run against the specified **SQL warehouse**.

### Alert

Select a **SQL alert** to evaluate using the specified **SQL warehouse**.

(Optional) Add **Subscribers** to notify with the results of the alert.

### File

Use **File** to run a `.sql` file using the specified **SQL warehouse**.

The file can contain multiple SQL statements separated by semicolons (`;`).

You must configure a **Source** for the SQL file using one of the following options.

#### Workspace

Use **Workspace** to configure a SQL file stored as a workspace file.

1. Click the **Path** field. The **Select SQL file** dialog appears.
2. Browse to the SQL file, click to highlight the file, and click **Confirm**.

> [!NOTE]
>
> You can use this option to configure a task for a SQL file stored in a Databricks Git folder. Databricks recommends using the **Git provider** option with a remote Git repository to version assets scheduled with jobs.

#### Git provider

Use **Git provider** to configure a SQL file stored in a remote Git repository.

The options displayed by the UI depend on whether or not you have already configured a Git provider elsewhere. Only one remote Git repository can be used for all tasks in a job. See [Use Git with Lakeflow Jobs](https://docs.databricks.com/aws/en/jobs/git.md).

The **Path** field appears after you have configured a git reference.

Enter the relative path for your SQL file, such as `etl/bronze/ingest.sql`.

> [!IMPORTANT]
>
> When you enter the relative path, don't begin with `/` or `./`. For example, if the absolute path for the SQL file you want to access is `/etl/bronze/ingest.sql`, enter `etl/bronze/ingest.sql` in the **Path** field.

## Finalize job configuration

1. (Optional) Configure **Parameters** as key-value pairs referenced in the configured SQL asset. To pass parameters to an alert, use the [SQL alert task](https://docs.databricks.com/aws/en/jobs/tasks/alert.md#parameters) instead. See [Configure task parameters](https://docs.databricks.com/aws/en/jobs/task-parameters.md).
2. (Optional) To configure retries, run-duration or streaming-backlog thresholds, or notifications, see [ Advanced task settings](https://docs.databricks.com/aws/en/jobs/configure-task.md#advanced).
3. Click **Save task**.

To edit, clone, disable, or delete this task, see [Configure and edit tasks in Lakeflow Jobs](https://docs.databricks.com/aws/en/jobs/configure-task.md).

## <a id="additional-resources" />Additional resources

* [SQL task](https://docs.databricks.com/aws/en/dev-tools/bundles/job-task-types.md#sql-task): Define a SQL task as code with Declarative Automation Bundles.
* [Configure task parameters](https://docs.databricks.com/aws/en/jobs/task-parameters.md): Pass parameters to the SQL asset.
* [SQL warehouse types](https://docs.databricks.com/aws/en/compute/sql-warehouse/warehouse-types.md): Choose a SQL warehouse type.
