Text to SQL, How Plain English Becomes a Query Your Database Can Run

A sales manager asks which customers spent the most last quarter. The analyst is busy, the answer takes two days, and by the time it arrives the quarter has moved on. The promise of this technology is simple. Ask the question in plain English and get the number in seconds, straight from the database.
The promise holds more often than the first demo suggests, and less often than the sales page claims. This guide covers the gap. The accuracy table with dates and splits, the six-stage pipeline, a semantic layer template, a worked wrong answer, and the build cost.
Text to SQL turns a question in plain English into a SQL query that runs against your database and returns the answer. A language model writes the query from your schema and a few business definitions, then the system checks it, runs it under a read-only role, and shows the SQL beside the result so you can check it.
If you would rather have this built and run as a service, let us discuss your project. Write to sales@denebly.com or call +1 (214) 896-2906.
What it is, and what it is not
It is a system that turns a natural language question into a SQL query, runs it against a specific database, and returns the rows. The model reads the question plus a description of the schema and writes the query. The closest cousin is retrieval-augmented generation, with one swap. A document system retrieves passages of text, while this system retrieves the schema itself, the tables, columns and join paths the query has to touch, and the database plays the part of the knowledge source. The shorthand for the field is NL2SQL.
The field is older than the current models. WikiSQL, a 2017 Salesforce set of simple single-table questions, and Seq2SQL, the model released with it, were the early proving ground, before Spider made the questions cross tables and databases.
| What people think it is | What it actually is |
|---|---|
| A chatbot that knows your data | A pipeline that reads your schema and writes SQL |
| Prompt engineering with cleverer wording | A prompt assembled from retrieved schema, definitions and examples |
| A bigger model with a longer memory | The same model with better context and stricter checks |
| Fine tuning by another name | No weights change, the model reads your schema at query time |
| A search box with SQL on top | Generation plus validation plus read-only execution |
The boundary with retrieval matters. A RAG system searches documents and hands passages to the model. This system searches the schema and hands table and column definitions to the model. When the retrieved context is wrong, the answer is wrong, and it still reads well.
The test that decides whether a setup works is plain. Ask a question whose answer changed after the model was trained. If the answer uses the new fact, the system works. Run that test on your own questions before you trust any number it returns.
How accurate it really is
The headline numbers come from one paper and one agent framework. The Spider 2.0 paper, by Lei and colleagues at ICLR 2025, reports that the same o1-preview code agent framework solved 91.2 percent of Spider 1.0 tasks, 73.0 percent of BIRD tasks, and 21.3 percent of Spider 2.0 tasks. Its databases often hold over 1,000 columns and live in systems such as BigQuery and Snowflake, with solutions that can run past 100 lines of SQL across several dialects. Clean, small schemas are close to solved. Real warehouses, with ambiguous columns, undocumented rules and thousands of fields, are not.
| Benchmark | Split and date | Top system | Score |
|---|---|---|---|
| Spider 1.0 | Full set, paper Nov 2024 | o1-preview agent framework | 91.2 percent |
| BIRD | Full set, paper Nov 2024 | Same framework | 73.0 percent |
| Spider 2.0 | Full 632 tasks, paper Nov 2024 | Same framework | 21.3 percent |
| Spider 2.0 | Project site, after suite fixes | o1-preview | 17.1 percent |
| Spider 2.0-Snow | 547-example split, leaderboard Oct 2026 | Genloop Sentinel Agent v2 Pro | 96.70 percent |
| Spider 2.0-Lite | Leaderboard, Nov 2026 | Tianqiong Data Agent | 76.23 percent |
| Spider 2.0-DBT | Leaderboard, Nov 2026 | SignalPilot | 65.6 percent |
| BIRD | Single Model track, Jun 2026 | Gemini-SQL2, Gemini 3.1 Pro | 80.04 percent |
| BIRD | Test set, Sep 2026 | AskData, AT and T | 83.40 percent |
| BIRD | Test set, Sep 2026 | GrainSQL | 82.95 percent |
| BIRD | Human baseline | People | 92.96 percent |
| BEAVER | Private warehouses, paper May 2026 | Best ReFoRCE agent | 11.4 percent |
Read the table down the split column, not across the scores. The 21.3 percent figure covers the full 632-problem set, while the 96.70 covers the 547-example Snow split. They are not a before and after. The project site now quotes 17.1 percent for o1-preview after evaluation-suite fixes. A tuned agent on one split can look near perfect while the same benchmark still defeats a general agent on the full set.
The newest results also carry a warning. A January 2026 audit by Jin and colleagues found annotation errors in 62.8 percent of the 121 Spider 2.0-Snow tasks with public gold SQL and 52.8 percent of BIRD Mini-Dev, and re-scoring moved rankings by up to nine places. Treat every leaderboard top as a snapshot with a date and a split.
One row matters more than the rest for a small business. BEAVER tests private warehouses, 9,128 question pairs across three of them, and off-the-shelf GPT-4o and Llama3-70B score near 0 percent end to end. The best agent in that paper reaches 11.4 percent with Claude-4.5-Sonnet, while the same agent scores 62.9 percent on Spider 2.0. Your warehouse is private too. Public leaderboard numbers are the ceiling, not the forecast.
How one question becomes SQL
A working system is a small pipeline, not one prompt. The model does one step, generation. Everything before it decides what the model sees, and everything after it decides what is allowed to touch the data. Six stages carry one question from plain words to checked rows.
Link the schema
This step is called schema linking. Find the tables and columns the question needs. For a database with five tables you paste them all. For a warehouse with thousands, embed each table description, embed the question, and pull the top 5 to 10 most similar tables. The DEV blueprint puts it plainly. The single biggest accuracy lever is the schema context you feed the model, and dumping the whole schema makes the model less accurate, not more. Our RAG pipeline guide works the same retrieval math on documents, and our hybrid search guide sets out the keyword plus vector fusion.
The finding half of this step has its own names. Pulling the candidate tables out of a large schema is schema retrieval, and cutting thousands of tables down to the handful a question can touch is schema pruning. Skip the pruning and the model reads tables it should never see, and answers slow down and wander.
Assemble the context
This stage is context assembly. Add what the schema alone cannot say. Column meanings, enum values, join paths, business definitions, and a few verified question-to-SQL examples. Three good examples often beat a thousand words of instruction. They teach the model your conventions, that revenue is in cents, that active means a status plus a recent login, that every join carries the tenant id.
The same definitions settle disambiguation, which column or metric a word means when two readings exist, so the model never has to guess between them. Entity resolution does the matching one level down, tying a name in the question to the one customer or product row it refers to. Value grounding ties the words in the question to the values actually stored, so Pro in a question finds the plan row whose name is Pro.
Generate the SQL
The model writes the query in the right dialect, one SELECT, nothing else. Ask for a short plan first, or for a typed reply with the SQL in one field, and reliability rises. The prompt carries a system message, the retrieved schema, the examples, hard rules such as read-only and always LIMIT 1000, and the question itself.
Validate the SQL
Never run a generated query straight against the database. Parse it with a parser such as sqlglot. Walk the parsed tree and reject anything that is not a SELECT, anything that touches a table outside the allowed list, and anything without a LIMIT. Then dry-run it with EXPLAIN, which checks the plan without executing the query. If the estimated cost is above your threshold, refuse it.
Execute under a read-only role
Run the query as a dedicated role with SELECT only on the tables you exposed, a statement timeout, and the session set to read-only. For multi-tenant apps, layer row-level security on top, so even a broad query only sees the calling tenant’s rows. The role is the layer that holds when every other check has a bug.
Show the answer and the SQL
Return the rows, the SQL, and a plain note on what was counted and filtered. Showing the SQL is what makes the answer auditable. The first time a number looks off, the SQL is the only way to find why. A system that hides the query removes the main way to catch errors.
Here is the pipeline working on one question, from the DEV blueprint by the Draxlr team. A SaaS app asks, what was our MRR from Pro customers in April. Retrieval pulls subscriptions, plans and users. Generation produces the query below, validation parses it cleanly, and execution under the read-only role returns 48,372.00 dollars.
The cancelled_at check keeps a subscription that ended mid-April out of the April total, and the division by 100.0 turns cents into dollars. Both are details a model guesses wrong when the schema description leaves them out, which is why the definitions file in the next section matters more than the model choice.
SELECT SUM(s.mrr_cents) / 100.0 AS mrr_dollars FROM subscriptions s JOIN plans p ON p.id = s.plan_id WHERE p.name = 'Pro' AND s.status = 'active' AND s.started_at BETWEEN '2026-04-01' AND '2026-04-30' AND (s.cancelled_at IS NULL OR s.cancelled_at >= '2026-05-01') LIMIT 1000;

The semantic layer starter template
Two studies agree. In the dbt Labs benchmark of 7 April 2026, on ACME Insurance with 11 questions run 20 times each, GPT-5.3 Codex scored 84.1 percent on the raw schema and 100 percent through the dbt Semantic Layer, while Claude Sonnet 4.6 moved from 90.0 to 98.2 percent.
Rumiantsau and Fokeev tested three frontier models on 100 questions over a retail dataset. With the schema alone the models scored 45.5 to 50.5 percent. With the schema plus a 4 KB hand-written definitions file they scored 67.7 to 68.7 percent, a gain of 17 to 23 points. The paper, arXiv 2604.25149 from 28 April 2026, calls it a structural result.
Snowflake reports the same shape from its own tests. Claude 3.5 Sonnet scored 57 percent without a semantic model and 78 percent with one, and Snowflake Cortex Analyst scores 90 percent or higher once the semantic model is real, against 51 percent for a single-prompt GPT-4o. Those are Snowflake numbers on a 150-question internal set, not independent results, and they still point the same way.
Write the metric definitions
Start with the 20 metrics people ask about most. For each one, write the plain definition, the exact SQL formula, and what it excludes. The table below is a starter template for a small online shop. Copy the shape and swap in your own tables.
| Metric | Plain definition | SQL formula | What it excludes |
|---|---|---|---|
| Revenue | Money kept from orders, after refunds | SUM(oi.quantity * oi.unit_price) | Refunded lines, tax, shipping |
| Active customer | A customer with an order in the last 90 days | MAX(o.order_date) within 90 days | Test accounts, cancelled orders |
| Average order value | Item revenue divided by order count | SUM(oi.quantity * oi.unit_price) / COUNT(DISTINCT o.id) | Tax, shipping, refunded lines |
| Churned customer | No order in the last 180 days | MAX(o.order_date) older than 180 days | Seasonal buyers flagged by hand |
Four rows is enough to start. The model stops inventing a formula per question and starts using yours. When two questions use the same word for different things, the definitions file is where the difference lives, written once, with the SQL beside it.
Map the join paths
Write down the joins the team uses every day, with the bridge tables included. Customers join to orders, orders join to order_items, order_items join to products. The model needs the path spelled out. The ASOasis guide adds a useful rule. Build the join graph from primary and foreign key metadata, find the minimal path between the tables a question names, and penalize fan-out, the case where a join multiplies rows and inflates a total.
Collect verified queries
Keep a file of question and SQL pairs that a person has checked. These are the golden queries. Use them as few-shot examples in the prompt and as regression tests when the prompt or the model changes. When a corrected answer comes back from a user, add it to the file. The file grows by one row per fix.
The wrong answer that runs
The most dangerous failure is not a query that errors. It is a query that runs, returns a clean number, and is wrong. The DataAspirant guide works one such case on the Chinook music store database, and the numbers are worth reading slowly.
The question is simple. How much revenue did Iron Maiden bring in. The correct query sums the price times the quantity on each invoice line. The wrong query sums the invoice total after joining the invoice table to its lines. This is a fan-out error, a join explosion. The join repeats each invoice total once per line, so the total grows with the number of lines.
SELECT SUM(il.UnitPrice * il.Quantity) AS revenue FROM InvoiceLine il JOIN Track t ON t.TrackId = il.TrackId JOIN Album a ON a.AlbumId = t.AlbumId JOIN Artist ar ON ar.ArtistId = a.ArtistId WHERE ar.Name = 'Iron Maiden';
SELECT SUM(i.Total) AS revenue FROM Invoice i JOIN InvoiceLine il ON il.InvoiceId = i.InvoiceId JOIN Track t ON t.TrackId = il.TrackId JOIN Album a ON a.AlbumId = t.AlbumId JOIN Artist ar ON ar.ArtistId = a.ArtistId WHERE ar.Name = 'Iron Maiden';
The correct query returns 138.60. The wrong query returns 1,233.54. The store total tells the same story. The correct figure is 2,328.60. The wrong figure is 20,848.62, nine times too high. One invoice shows the mechanism. Invoice 5 has a total of 13.86 and 14 lines, so the wrong query counts 13.86 fourteen times. Nothing errored. The query parsed, ran, and returned a confident wrong number.
The spot check that catches it takes two minutes. Pick one artist, add up the invoice lines by hand, and compare the sum with the invoice total for the same artist. If the two disagree, the join is multiplying rows. Never trust a total you have not reconciled against one source row.
A second worked case shows the same failure in a smaller shape. The JustMalhar guide builds a two-table shop and asks for total October 2026 revenue from customers in Surat. The correct query returns 1,200. A query that drops the October condition runs fine and returns 2,400, double the true figure. The dropped filter is the dangerous line, because no guardrail catches it. Only an evaluation against a known answer does.
There is a third case that should worry you more than the first two. Group revenue by the customer country instead of the invoice billing country, and the query passes execution accuracy on Chinook as shipped, because the two columns agree on the test data. Change one invoice billing country to Canada on a perturbed copy and the same query fails. The test set cannot see the error, so the score cannot either. This is test-suite accuracy, scoring on changed data, so build a perturbed copy of your own data and score against that too.
Validation before anything runs
Validation is deterministic code that decides whether a query is safe and well-formed. It is not a second model call, and it is not a feeling about the answer. The DataAspirant guide lists six checks, and each one catches a different failure.
| Check | What it does | What it catches |
|---|---|---|
| 1. Parse | Parse the SQL without running it | Syntax errors, made-up columns |
| 2. Read-only | Reject anything that is not a SELECT | Writes, deletes, schema changes |
| 3. Schema | Check every table and column exists | Hallucinated names |
| 4. Privacy | Block personal data in the result | Leaked names, emails, salaries |
| 5. Limit | Add a row cap, max 100 rows | Runaway result sets |
| 6. Dry run | Run EXPLAIN before the real run | Queries the planner rejects |
The lint step deserves a line of its own. Walk the parsed query tree and reject anything that is not a SELECT, anything that references a table outside your allowed list, and anything without a LIMIT. The DEV blueprint shows the shape in a few lines of sqlglot code. This is your defence against a model that decides DELETE FROM users is a reasonable answer.
When a check fails, feed the error back to the model for a corrected attempt, with a cap of two or three retries. This repair loop is called self-correction, and it is where the score moves. It is also the seam where a fixed pipeline shades into agentic analytics, the system reading its own error and deciding the next attempt instead of failing loudly.
A Medium guide by AI Engineering Foundry ran the same local model, qwen2.5-coder 7b, on the same 32 questions against the same SQL Server database, three times. The naive prompt scored 17 of 32 correct, 53 percent. A schema-aware prompt scored 26 of 32, 81 percent. Adding parser validation, a cost check and a repair loop scored 28 of 32, 88 percent. The model never changed.
Our structured outputs guide shows the other half of this work. Typed fields make the reply parseable, so the validator can check the shape before the query ever reaches the database.

Security, the read-only role that holds
A user who can type questions can try to make the model write queries over data they should not see. The OWASP 2025 list of LLM risks puts prompt injection first and improper output handling fifth. A 2025 study from ICSE showed prompt-to-SQL injection working against LangChain SQL apps across seven language models. The database role is the layer that holds when the model is fooled.
Parameterized queries are the standing defence wherever your own code builds a query around what the model produced, the first recommendation in the OWASP cheat sheet on query parameterization, because values travel as data and never become SQL text.
Build the role before the first question arrives. Create a dedicated login, grant SELECT only on the tables you exposed, set a statement timeout of 10 seconds, and set the session to read-only. Granting SELECT only on specific tables means even a perfectly crafted injection cannot touch your secrets table. For multi-tenant apps, add row-level security keyed to the current user, so a query that forgets the tenant filter still returns only that tenant’s rows.
Read-only access is necessary but not enough. A read-only query can still read data the asker should not see, and a correct query can still scan a 10 TB table and land a warehouse bill. Match the database role to the permissions of the user asking, keep the row limit and the timeout in place, and put a cost cap on warehouses that bill per byte scanned. Run against a replica or a warehouse, not the live transactional database, whenever you can.
What it costs to run for a small business
The cost question has two sides, and most pages only price one of them. The build side has almost no licence line, because the parts are free. The buy side has a clear monthly price, because the vendor runs the parts for you. Work both sides before you choose.
The build side of the bill
The software costs nothing. Ollama runs a local model on your own machine, SQLite holds the test database, sqlglot parses the query, and the pipeline code is about 150 lines of Python in the Aimadetools tutorial. The bill is the model calls plus the developer time to build the validation layer and keep the definitions file current. Free tiers cover the first try. Databricks Genie carries a free allowance of 150 DBUs, about 10.50 dollars in US East, Chat2DB has a free tier, and AI2SQL runs 3 queries a day on a demo database for free.
The buy side of the bill
The table below lists starting prices from the vendors’ own pages, as the comparison pages recorded them in November 2026. Check the price on the day you buy, because one tool in this list prints three different prices on three different pages.
| Tool | Starting price | One year |
|---|---|---|
| AI2SQL Start | 9 dollars a month | 108 dollars |
| Draxlr | 25 dollars a month | 300 dollars |
| Metabase plus AI add-on | 85 plus 100 dollars a month | 2,220 dollars |
| WrenAI Essential Cloud | 179 dollars a month, billed annually | 2,148 dollars |
| WrenAI Enterprise | 559 dollars a month | 6,708 dollars |
The gap between the cheapest and the dearest row is about sixtyfold, and the dearest row is not sixty times better. A small team that asks a few hundred questions a month pays the bottom row, not the top one. The trap is seat pricing. AskYourDatabase prints 39 dollars a month on one comparison table, 10 dollars per user per month on another, and 49 dollars per seat per month on its own table. Three figures, one tool. Multiply the per-seat figure by your team size before you compare it with a flat monthly price.
If the numbers above look small enough to try, let us discuss your project. Write to sales@denebly.com or call +1 (214) 896-2906.
Buy or build, the tools and their prices
The tools fall into three groups, and the group decides the price more than the brand does. Developer frameworks give you the pipeline and you run it. AI data analysts give you a chat box over your warehouse. AI-assisted SQL clients give you a better editor. The AIforDatabase comparison draws the same three-way split. The warehouse platforms sell the chat box as talk to your data, and Google markets the BigQuery version as conversational analytics.
| Tool | Starting price | Best for | Watch out |
|---|---|---|---|
| Draxlr | 25 dollars a month | Small teams on Postgres | Check the dialect list first |
| AI2SQL | 9 dollars a month | Analysts who want SQL fast | Per-agent keys need managing |
| Chat2DB | Free tier | Developers who live in SQL | Free tier limits apply |
| SQLAI.ai | Free tier | Quick one-off queries | Paid tier from 6 dollars a month |
| Hex | 28 dollars per user a month | Notebooks plus questions | Seat cost grows with the team |
| Metabase | 85 plus 100 dollars a month | Teams already on Metabase | AI add-on costs more than the base plan |
| WrenAI | 179 dollars a month | Teams that want a semantic layer | Enterprise tier is 559 a month |
| Vanna | Cloud from 50 dollars a month | Self-hosted RAG over SQL | Repository archived after v2.0.2 |
| Julius AI | From 20 dollars a month | Analysts on spreadsheets and files | Check the connectors first |
| Querio | Near 14,000 dollars a year | Large teams, governed access | Far above a small team budget |
| Sequel AI | From around 99 dollars a month | Governed self-service analytics | Starting price is approximate |
| dbForge AI Assistant | 200 to 400 dollars per user a year | SQL Server shops | Per-user licence, yearly |
Two warnings belong beside this table. First, the Vanna repository was archived after version 2.0.2 on 2 February 2026, so a team that builds on it today builds on frozen code. Second, the Fastero comparison claims the best tools get it right roughly 70 to 85 percent of the time on real schemas. That sits well above the 21.3 percent the Spider 2.0 paper records for a general agent on enterprise workflows. Believe the number that matches your schema, and measure it yourself before you sign.
The decision rule is short. Buy when the schema is standard, the team has no developer time, and the questions are ordinary. Build when the schema is odd, the data is private, or the questions need your definitions to come out right. The build keeps the data inside your walls. The buy saves the month of building and the ongoing care of the validation layer.
How to measure it on your own questions
No leaderboard score predicts your accuracy, because no leaderboard holds your schema. Build a golden set of 50 to 200 real business questions with expected results, the range the Coderhouse guide recommends, and compare result sets, not SQL strings. Two different queries can return the same correct answer, and the same SQL text can be wrong on your data. Each checked pair in the set is golden SQL, the question with its verified query and its verified result, and the set itself is your evaluation set.
Score the set with execution accuracy, the share of queries whose results match the correct results, and keep a second score on a perturbed copy of the data, where one or two values have been changed by hand. The perturbed copy catches the lucky pass, the query that is right on the test data and wrong on the next invoice. Only an evaluation against a known answer catches a dropped filter.
BIRD publishes a second metric beside execution accuracy, the Valid Efficiency Score, which also weighs how efficiently a correct query runs, so a right answer from a wasteful scan earns less than the same answer from a lean query. Track your own eval pass rate, the share of the set the system passes, on the clean data and the perturbed copy alike.
Run the set on every change, a new chunk size, a new prompt, a new model, a new corpus version. The UST study shows why the knobs matter. Metadata lifted BIRD accuracy from 66.5 to 73.8 percent, and the optimized AxisSQL configuration reached 76.86 percent execution accuracy on the BIRD hidden test, a gain of 1.79 points.
Candidates flatten near 12, so generating more than a dozen buys little. Execution-grounded aggregation raised accuracy from 69.8 to 73.8 percent for roughly 25 percent more tokens, against 71.4 percent for self-consistency voting. Simple questions scored 85.4 percent, moderate 72.6 percent, challenging 56.8 percent. Your set will have its own split, and the split tells you where the work goes.
Log every question and every query the system runs. The log is the raw material for the next round of examples, the next definitions, and the next eval cases. Our LLM evals guide sets out the same discipline for any language model system.
Dates, dialects and definitions, the three quiet breakers
Three small things break more queries than any model weakness. Dates first. Language models are oddly bad at last week against the last 7 days against the previous calendar week. Resolve relative time expressions in your code before generating SQL, and inject explicit dates into the prompt. A question that says last month should reach the model as a date range.
Dialects second. PostgreSQL uses LIMIT, SQL Server uses TOP, BigQuery and Snowflake use their own date functions, and identifier quoting changes with the platform. The AnyGen guide lists the traps. LIMIT against TOP, date_trunc against DATE_TRUNC against DATETRUNC against DATE_FORMAT, and parameter markers that change from one dollar sign to an at sign to a question mark. Never ask for standard SQL if the query will run on one platform. Name the dialect in the prompt and in the system message.
Definitions third, and this is the one that costs the most. Active customer, revenue and churn have definitions that live in people’s heads or in a BI tool, not in the schema. The model will invent a reasonable definition, which is worse than an error, because a reasonable definition returns a clean number that no one questions. The semantic layer exists for exactly this reason. Write the definition once, in plain words, with the SQL beside it, and the model stops inventing.
Mistakes that ship wrong numbers
Most failed builds share the same mistakes. A stale definitions file, a join that multiplies rows, a query the user never sees, no measurement, and a leaderboard number quoted without its split. Seven items, each with its fix.
- Dumping the whole schema in the prompt. Fix – retrieve the top 5 to 10 tables and leave the rest out.
- Measuring success by whether the query runs. Fix – score the result against a known answer.
- Giving the model a role that can write. Fix – a read-only role, SELECT only, with a timeout.
- Leaving business terms undefined. Fix – write the 20 definitions first.
- Hiding the SQL from users. Fix – show the query beside every answer.
- Skipping the eval set. Fix – 50 real questions with known answers before launch.
- Trusting a leaderboard number without its split and date. Fix – read the split, the date and the system before you quote the score.
Who should build one, and who should skip it
A text-to-SQL setup earns its keep when the same questions arrive daily and the answers sit in a database no one person holds in memory. Support teams, internal help desks, sales teams answering product questions, and any team whose numbers live in a database that changes weekly.
Skip it when the questions have no database behind them. General knowledge, opinion and creative writing need no SQL. Skip it too when the schema is tiny or frozen. A five-table database that never changes is better served by pasting the schema into the prompt. A frozen schema does not need a pipeline behind it.
How Denebly builds it
Denebly builds this as one connected system. The work starts with your schema and your questions, not with a model choice.
The deliverables are fixed before work starts. The audited schema slice, the definitions file with your 20 metrics, the prompt with its clarification hatch, the validation gate with its six checks, the read-only role, and the 30-day numbers, the execution accuracy on your own 50 questions, before and after.
If you want the build and the first month of tuning handled for you, let us discuss your project. Write to sales@denebly.com or call +1 (214) 896-2906.
The rule to work by
Write the 20 definitions first, build the 50-question golden set second, then let the model write SQL. Check one number by hand every week, and add every correction to the golden set. The work is not teaching a model to write SQL. The work is writing down what your business means, so natural language to SQL has something true to stand on.
If you would rather hand the build to a team, write to sales@denebly.com or call +1 (214) 896-2906 and ask for a plain English query build. We start with your schema and your questions.
Frequently asked questions
What is text to sql
It is a system that takes a question in plain English and returns rows from a database, by writing SQL for that database. The model does the writing, and the pipeline around it does the checking, the running and the showing of the query.
How accurate is text-to-SQL
On clean benchmark schemas, tuned agents score above 90 percent. On real enterprise workflows the same class of system scores far lower, 21.3 percent for the o1-preview agent framework on Spider 2.0. On your own schema, the honest answer comes from your own golden set, not from a leaderboard.
Is it safe to run on a production database
Only with guardrails. A read-only role, permissions matched to the asking user, validation before execution, row limits, timeouts and cost caps. Never run model-written SQL with write access, and run it against a replica when you can.
Do I need to fine-tune a model
No, not to start. A strong general model with a good schema description, clear definitions and a few verified examples is the normal starting point. Fine-tuning earns its place later, when the schema is fixed, the examples number in the hundreds, and a smaller model would cut the running cost.
What does a semantic layer do
It writes down, once, what each metric means and how to compute it, so the model uses your definition instead of inventing one per question. In one study a 4 KB definitions file lifted accuracy by 17 to 23 points. Start with the 20 metrics people ask about most.
How much does it cost to run each month
The cheapest bought route in this article starts at 9 dollars a month, and the dearest starts at 559 dollars a month. The built route has no licence line, so the bill is model calls plus care of the validation layer. Check the price on the day you buy.
Sources
- Lei and colleagues, Spider 2.0, arXiv 2411.07763, ICLR 2025, read 29 November 2026.
- Li and colleagues, BIRD, arXiv 2305.03111, read 29 November 2026.
- Rumiantsau and Fokeev, Semantic Layers for Reliable LLM-Powered Data Analytics, arXiv 2604.25149, 28 April 2026, read 29 November 2026.
- Jin and colleagues, audit of Spider 2.0 and BIRD annotations, arXiv 2601.08778, January 2026, read 29 November 2026.
- Google Cloud, techniques for improving SQL generation from plain English, 16 May 2025, read 29 November 2026.
- Tool prices in this article, from the vendors’ own pricing pages as listed by the comparison pages named in the text, with prices checked 2 November 2026.

WRITTEN BY
Arslan Mushtaq
Founder, Denebly
Arslan founded Denebly in 2018 and leads its AI development work for startups and mid-size businesses, across AI chatbots, agentic workflows, RAG systems, machine learning and automation. Denebly has delivered 100+ projects from Dallas, Texas.
Ready to Solve Your Business Problems With AI?
Tell us what you are trying to build, automate or fix. You will get an honest assessment within one business day, not a sales pitch.