# MD_RUN_FLIGHT
> Trigger an on-demand execution of a Flight using its current version.
Triggers a new run of a [Flight](/concepts/flights) using the Flight's current version. The run is asynchronous: `MD_RUN_FLIGHT` returns immediately with a `RUN_STATUS_RUNNING` (or `RUN_STATUS_PENDING`) row. Use [`MD_FLIGHT_RUNS`](../md-flight-runs) to poll for completion and [`MD_FLIGHT_LOGS`](../md-flight-logs) to read the output.

## Syntax

```sql
SELECT * FROM MD_RUN_FLIGHT(flight_id := '<flight_id>');
```

`MD_RUN_FLIGHT` is a table function; you can also call it with `CALL` when you don't need the result row:

```sql
CALL MD_RUN_FLIGHT(flight_id := '<flight_id>');
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight to run. |

## Return columns

| Column | Type | Description |
|---|---|---|
| `flight_id` | `UUID` | The Flight identifier. |
| `flight_name` | `VARCHAR` | The Flight name. |
| `flight_version` | `INTEGER` | The version this run locked to. |
| `status` | `VARCHAR` | Initial run status (`RUN_STATUS_PENDING` or `RUN_STATUS_RUNNING`). |
| `is_scheduled` | `BOOLEAN` | `false` for on-demand runs. |
| `created_at` | `TIMESTAMP WITH TIME ZONE` | When the run was created. |

## Behavior

- The new run locks to the Flight's current version. Subsequent updates to the Flight do not affect this run.
- The run number is assigned sequentially per Flight and visible through [`MD_FLIGHT_RUNS`](../md-flight-runs).
- Multiple concurrent runs of the same Flight are allowed; each gets its own run number.

## Examples

Trigger a run and capture the row:

```sql
SELECT flight_version, status
FROM MD_RUN_FLIGHT(flight_id := '80000000-0000-0000-0000-000000000001');
```

Trigger and then poll until the run finishes:

```sql
-- Kick off the run
CALL MD_RUN_FLIGHT(flight_id := '<flight_id>');

-- Poll the latest run's status
SELECT run_number, status
FROM MD_FLIGHT_RUNS(flight_id := '<flight_id>')
ORDER BY run_number DESC
LIMIT 1;
```

## Related

- [`MD_FLIGHT_RUNS`](../md-flight-runs) — List runs for a Flight.
- [`MD_FLIGHT_LOGS`](../md-flight-logs) — Read combined stdout/stderr for a run.
- [`MD_CANCEL_FLIGHT_RUN`](../md-cancel-flight-run) — Cancel an in-progress run.
- [`run_flight` MCP tool](/sql-reference/mcp/) — AI-agent equivalent.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/flights/md-run-flight/",
  "page_title": "MD_RUN_FLIGHT",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
