Home · Business · IT, Data & Security · Software development
As of 13 August 2026, AI can only partly write SQL queries for your business database.
This still needs a person who signs their name to it.
Can you do it?
5 minutesto a draft.
30 minutesto something you’d act on.
Cost, all in£0
Skill neededchat-fluent
Who has to check ityou
What the alternative costsCursor is an AI code editor that can help a developer draft and revise SQL, but no price is supplied here.
If this goes wrong: the query returns a misleading business figure, exposes data, or places unnecessary load on a live database.
What to actually do
Hand it to a person
The route this page recommends
A person who owns the outcome does this end to end, worth it when the failure is dear.
Use a tool built for this
Second choiceDo it yourself
The distant thirdA chat interface, chat-fluent skill, and roughly 30 minutes until you can act on the result.
How to actually do it
- Open your database documentation, administration console or schema export and gather the SQL dialect, database version, relevant table names, columns, data types, primary keys and foreign keys.
- Remove customer names, email addresses, account numbers and other unnecessary personal data, then paste the remaining schema and the exact reporting question into the prompt.
- Add the required date range, filters, grouping rules, exclusions, sorting and expected output columns, defining any business term that could have more than one meaning.
- Add anonymised test cases or known totals, select read-only access in the database tool, and ask the model to produce the query and validation checks using the prompt.
- Run the query first in a development environment or against a limited sample, then compare its row counts, totals and sample records with your known test cases.
- Inspect the execution plan or ask your database administrator to check joins, indexes, permissions, personal-data exposure and load before running it on the live database.
- Save the verified query with its schema version, assumptions and owner, then send it to the report or automation that needs the result.
Prompt
Write a SQL query for the business reporting task below. Use only the supplied schema and facts. Do not invent tables, columns, relationships, values or business rules. If anything needed is missing, ask focused questions before writing the query. SQL dialect and database version: [for example, PostgreSQL 15, MySQL 8, SQL Server, or SQLite] Database schema: [Paste CREATE TABLE statements, a schema export, or a complete list of tables, columns, data types, primary keys and foreign keys. Do not paste customer names, contact details or other unnecessary personal data.] Reporting task: [Describe exactly what the result must show, including filters, date range, grouping, sorting, inclusion and exclusion rules, and the meaning of any business terms.] Expected output columns: [List the columns and labels you want returned.] Known checks: [Give one or more records, totals, or test cases whose correct result is already known, using anonymised or synthetic values where possible.] Requirements: 1. Produce a read-only SELECT query only. Do not write INSERT, UPDATE, DELETE, DROP, ALTER or other data-changing statements. 2. Explain each join, filter, grouping choice and assumption in plain English. 3. Flag any ambiguity instead of choosing silently. 4. Warn about duplicate rows, NULL values, date and time-zone handling, and performance risks where relevant. 5. Provide a small set of validation queries or checks that I can run against known results. 6. Format the final SQL clearly and identify the SQL dialect it uses.
Open it prefilled in ChatGPT or Claude, or copy it into Gemini, which takes no prefill link.
What it gets wrong
- AI cannot see your current schema, permissions, data quality or undocumented relationships unless you supply them.
- It cannot determine what a business term means when your team uses it inconsistently.
- It cannot prove that a result is correct when there is no trusted total, sample or independent report to compare against.
- It can write a syntactically valid query that duplicates rows, drops NULL values or produces a plausible but wrong total.
- It cannot take responsibility for a query that exposes data or consumes resources on a live database.
What caps this at PARTLY: verification cost, stakes of error and private data access.
How we scored this
Five axes, each scored nought to two by hand: ten means AI carries the task cleanly, and the thresholds that turn a total into YES, PARTLY or NO are published in the methodology. Each axis name links to its definition.
| Axis | Score (0–2) |
|---|---|
| Output | 2 |
| Inputs | 1 |
| Verification | 1 |
| Liability | 1 |
| Effort delta | 2 |
| Total | 7 / 10 |
The methodology and its thresholds are published in full.
FAQ
- Can ChatGPT write SQL queries for my database?
- Yes, it can draft SQL from a schema and a precise reporting requirement. It cannot see your database or know undocumented business rules, so run the result with read-only permissions and check it against known records before using it.
- Can AI connect directly to my business database?
- Some development and data tools can be connected to business systems, but a chat response should not be given unrestricted production credentials. Supply a limited schema or sanitised sample, and use a separate controlled environment for testing.
- How do I check whether an AI-written SQL query is correct?
- Run it against a safe copy or limited sample and compare row counts, totals and individual records with results you already trust. Also check joins, NULL handling, date boundaries, permissions and the execution plan before approving it for live use.
- Can AI write SQL for a complex business report?
- It can draft much of the query, including joins, common table expressions and aggregations, when the schema and rules are explicit. Complex reports still need a person who understands the data to resolve ambiguity and validate the result.
Nearby answers
Assessed by gpt-5.6-luna (gpt-5.6-luna) on 2026-08-13, second-checked by an independent model. Wrong somewhere? Email [email protected] and it gets re-checked.
The newsletter
AI news, new answers and product picks, straight to your inbox.