---
slug: ai-sql-editor
title: AI SQL Editor
section: Core Workflows
description: Describe preprocessing and transformations in plain English, generate editable SQL, and create an analytics-ready sheet.
listed: true
navOrder: 9
---
**AI SQL Editor lets you describe preprocessing and transformations in plain English, then generates readable SQL so OrcaSheets can create a new analytics-ready sheet from your original data.**

![Describing transformations and creating a sheet with AI SQL Editor](/images/docs/AI_sql_editor.gif)

## Think of it like a data prep assistant that writes the SQL for you

> Before analysis, raw sheets often need cleanup: rename columns, filter rows, cast types, join lookups, or reshape fields. **AI SQL Editor** takes those steps in English, turns them into SQL you can read and edit, then creates a new sheet ready for pivots, charts, and Chat.

## What is AI SQL Editor?

AI SQL Editor is where you define a preprocessing or transformation flow against an existing sheet. OrcaSheets generates the SQL, validates it, and creates a new sheet so the original data stays intact while you work from the cleaned version.

You:

1. **Open** AI SQL Editor from the left panel.
2. **Describe** the transformations you want in plain English.
3. **Generate** the SQL query and review it.
4. **Create Sheet** once the query is validated.
5. **Edit** the SQL later from the icon under the generated sheet if you need to tweak the flow.

## Why use it?

Import and connector data is rarely analysis-ready on day one. AI SQL Editor shortens the gap between "raw sheet" and "sheet I can trust for reporting".

For example:

- Drop nulls and normalise date columns before a cohort analysis.
- Derive a clean `revenue` field from price, quantity, and discount columns.
- Filter to active customers and reshape messy status labels into a consistent set.

You do not need to write the SQL yourself. Describe the steps, let AI draft the query, then edit it if something looks off.

## How to use AI SQL Editor

1. **Open** your project and select the sheet you want to transform.
2. **Click** the **AI SQL Editor** icon in the left panel.
3. **Describe** your preprocessing or transformation steps in English.
4. **Click** **Generate query SQL**.
5. **Review** the generated SQL. Edit it if needed.
6. **Click** **Create Sheet** once the query is generated and validated.

OrcaSheets creates a new analytics-ready sheet based on that query. Your original sheet remains available in the project.

## Edit the query on a generated sheet

On any sheet created by AI SQL Editor:

1. **Find** the **SQL query** icon underneath the sheet.
2. **Click** it to open the query.
3. **Modify** the SQL and re-apply when you want to update the sheet.

That keeps the transformation transparent: you can always see how the analytics-ready sheet was produced, and adjust it without starting over.

## Notes

- Describe steps clearly and reference real column names when you can. The generated SQL will be easier to validate.
- The generated query is readable and editable before and after you create the sheet.
- AI SQL Editor creates a **new** sheet. It does not silently overwrite your original data.
- For quick in-grid transforms, see [OrcAI](/docs/orcai). For exploratory questions, see [AI Chat Interface](/docs/ai-chat-interface).

## Related pages

- [OrcAI](/docs/orcai)
- [Using Macros](/docs/using-macros)
- [AI Chat Interface](/docs/ai-chat-interface)
- [Importing Data](/docs/data-import)
- [Data Import Errors](/docs/data-import-errors)
