Text-to-SQL

Text-to-SQL is the AI technique of turning a plain-language question into a SQL query, running it against a database and returning the result, so people can ask data questions without writing code.

What Is Text-to-SQL?

Text-to-SQL is the AI technique of turning a question written in plain language into a SQL query. Someone asks "What were sales by region last quarter?" and a large language model works out which tables and columns to use, writes the query, runs it and returns the answer.

Text-to-SQL sits behind many of the AI data assistants on the market. The same idea applies to other query languages. Against a Power BI semantic model, the AI writes DAX instead of SQL.

How Text-to-SQL Works

  1. Schema linking. The AI finds the tables, columns and relationships that match the words in the question.
  2. Query generation. It writes a query using what it found, including filters, joins and aggregations.
  3. Execution. The query runs against the database or semantic model.
  4. Explanation. The AI turns the result into a sentence, a table or a chart, ideally with the query shown.

Why Text-to-SQL Struggles on Raw ERP Tables

ERP databases are built for transactions, not questions. JD Edwards, for example, stores general ledger detail in the account ledger table (F0911), with coded column names and dates stored as numbers. Thousands of tables, cryptic names and rules that live outside the schema make schema linking hard.

The bigger problem is what the schema doesn't say. Which order types count as sales, whether revenue is stored as a negative credit, which currency each company reports in: none of that is in the column names. A generated query can run, return a number and look right while adding up companies in different currencies or counting canceled lines. A wrong answer that looks right is worse than an error.

How to Make Text-to-SQL Reliable

  • Give it governed measures. With a semantic layer, the AI picks a defined measure instead of writing the math.
  • Describe everything. Business names and descriptions on tables, columns and measures.
  • Narrow the scope. Expose the subject area a question needs, not the whole database.
  • Add examples. Sample questions with approved queries show the AI how the business asks.
  • Show the work. Display the measure, filters and date range used, so people can check the answer.
  • Test with traps. Include questions that tempt a wrong shortcut, such as mixed currencies.

Text-to-SQL vs Natural Language Query

Natural language query is the broader idea of asking data questions in everyday language. Text-to-SQL is one way to deliver it, by generating SQL. Other approaches map the question to predefined measures or approved answers instead of writing a new query each time.

Frequently Asked Questions

What's the difference between text-to-SQL and a semantic layer?

Text-to-SQL writes a new query from the raw schema each time. A semantic layer defines the measures, relationships and business rules once, so an AI tool can pick a governed measure instead of writing the math. Many AI tools now combine the two, generating queries against a semantic layer.

How accurate is text-to-SQL?

It depends on what the AI has to work with. Clear, well-described data with governed measures produces far better results than raw tables with coded names and business rules that live outside the database.

Is text-to-SQL the same as natural language query?

Text-to-SQL is one way to deliver natural language query. Natural language query is the broader goal of asking data questions in everyday words.

Can text-to-SQL work on ERP data?

It can run, but raw ERP tables don't carry the business logic needed for correct answers. It works much better against a semantic model that defines the measures.

Text-to-SQL and QuickLaunch's Approach

QuickLaunch Analytics gives AI tools governed measures to choose from instead of raw tables to decode. Each Application Pack, from JD Edwards and Vista to NetSuite and OneStream, carries its system's business logic in a governed semantic model, and QuickLaunch semantic models ship with the descriptions and instructions AI tools read. With Trusted Answers, a Claude plugin from QuickLaunch, each answer shows the measure, filters and source behind it, and labels each number Verified or Derived, so people know what they can act on. See our AI page.

More plain-English definitions of data, analytics and AI terms are in the QuickLaunch Learning Center.

About the Author

Avatar photo

Louie Benitez

Louie learned the product the practical way, by deploying it. After years on the implementation team getting customers live, he moved into sales engineering, where he now demos and scopes the solution for prospects. He writes from the delivery seat about what a real rollout looks like and where ERP data tends to break.

Related QuickLaunch Solutions and Products

Foundation Pack

Accelerate time to insight while lowering total cost of ownership by creating a unified and centralized business foundation with your CRM, ERP, and other data sources.

Key Features

  • Automated Data Pipelines
  • Governed Data Lakehouse
  • Enterprise Semantic Layer
  • Kept current through upgrades
Learn More About the Foundation Pack

JDE Pack

Finance, supply chain, manufacturing, job cost and payroll analytics for JD Edwards EnterpriseOne, with the business logic built and validated.

Key Features

  • 35 perspectives
  • 3,900+ measures
  • Income statement and balance sheet hierarchies
  • Automatic Julian date conversion
  • User-defined code translation 
Learn More About JD Edwards Analytics

Vista Pack

Purpose-built analytics for construction project intelligence, job costing, and operational performance.

Key Features

  • 15 perspectives
  • 3,000+ measures
  • Specialized job costing
  • Earned revenue calculations 
  • WIP & retention tracking 
Learn More About Vista Analytics

Spectrum Pack

Job cost, equipment and financial analytics for Viewpoint Spectrum, on a governed semantic model in Power BI or Databricks.

Key Features

  • Job cost by job and sub-job
  • Equipment costs
  • General ledger financials
  • Accounts payable and receivable
  • Power BI or Databricks
Learn More About Spectrum Analytics

NetSuite Pack

Core financials (GL, AP, AR) with multi-calendar financial reporting and cloud ERP analytics in Power BI.

Key Features

  • 3 perspectives
  • 650+ measures
  • 40+ relationships
  • Multi-subsidiary consolidation 
  • SuiteAnalytics integration 
Learn More About NetSuite Analytics

OneStream Pack

Financial planning, reporting, and consolidation analytics integrated with OneStream's Partner Place marketplace. 

Key Features

  • 550+ dimensions
  • 900+ measures
  • 25+ relationships
  • FP&A integration
  • Consolidation workflows
Learn More About OneStream Analytics

Get Your Custom Analytics Blueprint

See the ideas working in a live demo. We'll show the semantic model, the governed lakehouse and AI answers for JD Edwards, Vista, NetSuite, OneStream, Salesforce or Spectrum.

Get Custom Demo