---
description: Want to use your SQL somewhere else? We've got you covered.
---

# Export compiled SQL and Jinja-SQL

To export the full SQL (including all parent cells) for a particular cell, right-click on the cell and select the **Copy as** -> **Copy as SQL** option (or the **Export SQL** button in the design bar).

<figure><img src="https://2710183445-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTvbqOPoS6WricGDYVJya%2Fuploads%2FKVSu2r7wzlzpLJqIEzUY%2Fimage.png?alt=media&#x26;token=7a0c982d-24e7-4456-b936-2eb038c311c9" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Exporting SQL requires a canvas [analyst role](../../sharing-and-permissions/sharing-permissions).
{% endhint %}

A new panel will open showing:

* A preview of the compiled SQL for this cell
* An overview of all of the upstream cells that have been compiled into this export

<figure><img src="https://2710183445-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTvbqOPoS6WricGDYVJya%2Fuploads%2FxybZJu50EQdZlernONMc%2Fimage.png?alt=media&#x26;token=188c0c35-74cc-4a0b-ae9b-eec339e935f7" alt=""><figcaption><p>The DAG summary and full compiled SQL are displayed by default.</p></figcaption></figure>

#### SQL + Jinja

Selecting this option makes it possible to customise the number of upstream cells included in the exported SQL by selectively treating cells as [dbt models](../../database-connections/dbt-integration). Use this option to generate code that is compatible with dbt.

Clicking on a cell in the DAG summary will convert it to a model (indicated by the dbt symbol), which means that all cells further upstream need not be included in the compiled code. Any references to models are also converted to `ref()` invocations.

<figure><img src="https://2710183445-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTvbqOPoS6WricGDYVJya%2Fuploads%2FYoaClnJ2Q7lZT4DrnrjS%2Fimage.png?alt=media&#x26;token=eda11ed9-36d6-4597-b23f-240cbdbc4652" alt=""><figcaption></figcaption></figure>

Depending on the contents of your cells, other changes may be applied to the compiled code (especially if those cells contain more complex Jinja expressions). A summary of those changes is visible by clicking on **View code changes**.
