It usually arrives as a short message: can you send me the query behind that report? What you have is the query as it lives in application code or a saved snippet, one long line of lower case text with the filters buried in the middle. You can forward it as it stands, and your teammate will spend their first ten minutes doing what you could have done in ten seconds: pulling the string apart to find where the date range lives and which values they may change.
Formatting before you send is a small courtesy with an outsized effect. This guide shows how to prepare a query for handover with the free SQL Formatter on Ovatly, and covers the three habits that make the handover complete: keep the values exactly as written, name the dialect, and be honest that the query was prepared for reading rather than re-tested.
Contents
- Quick answer
- Why the one-line version wastes your teammate's time
- What a formatted handover gives them
- How to format SQL for a teammate, step by step
- Worked example: a monthly sales report query
- The three handover habits
- Limitations to state out loud
- Common mistakes
- FAQs
- Conclusion
Quick answer
Paste the query into the SQL Formatter, choose the dialect your database uses, press Format SQL, and send the result. Keywords come back in upper case, each clause sits on its own lines, and the filters and date range stand in plain view, ready to adjust. Formatting changes layout and keyword case only, so the query you send is the query you ran. Add one line naming the dialect, and one noting it was formatted for reading and has not been re-run.
Why the one-line version wastes your teammate's time
A report query answers questions beyond its own output. Your teammate rarely wants the identical report; they want last month instead of this month, one region instead of all of them, or the same shape of query pointed at a neighbouring table. Every variation starts with finding the values inside the statement: the dates in the filter, the status codes, the grouping.
In a one-line string, those values have no address. The date range sits somewhere after the table name and before the grouping, inside a line that must be read character by character, and the risk of editing the wrong literal is real: a query often contains several dates and several codes, and only some of them are the knobs. The sender knows which ones matter because they wrote the query. The recipient has to reverse-engineer that knowledge from the least readable form of the text.
What a formatted handover gives them
The formatter's layout is a map of the query. The select list sits at the top, one item per line, so the report's columns can be matched against the output at a glance. The table clause stands alone. The filter clause gets its own lines, where your teammate will spend most of their time, and each condition laid out separately makes the date range and status filter findable in seconds.
Upper case keywords do quiet work here too. When SELECT, FROM, WHERE and GROUP BY stand out from the identifiers around them, the skeleton of the query is visible before a single column name is read, and your teammate can jump straight to the clause they need. None of this changes the query: the literals they adjust are the literals you ran, exactly as written.
How to format SQL for a teammate, step by step
- Open the SQL Formatter and paste your SQL statement into the input box. If the report uses several statements, paste them together; they are formatted in sequence, separated by blank lines.
- Choose the dialect your database uses. The tool covers eight dialects, including PostgreSQL, MySQL and SQL Server.
- Press Format SQL.
- Read through the result once, as your teammate will: find the date range and the filters.
- Copy or download the formatted query, and send it with the dialect named and a note that it was formatted for reading, not re-tested.
Worked example: a monthly sales report query
Here is the kind of string that gets forwarded, a monthly sales by region report with a date filter, compressed onto one line:
select region, date_trunc('month', order_date) as sales_month, sum(total) as sales from orders where order_date >= '2026-01-01' and order_date < '2026-02-01' group by region, sales_month order by region
And here is the same statement after formatting:
SELECT
region,
date_trunc('month', order_date) AS sales_month,
sum(total) AS sales
FROM
orders
WHERE
order_date >= '2026-01-01'
AND order_date < '2026-02-01'
GROUP BY
region,
sales_month
ORDER BY
region
Nothing in the statement changed: the same columns, the same table, the same two dates, the same grouping. What changed is what your teammate can do with it in the first minute. The two dates sit on adjacent lines in the filter clause, clearly a pair, clearly the range to move for a different month. The grouping and ordering are separated, so the lines to touch for a different grouping are obvious. The literals are exactly as written, so an edit starts from the values that actually produced your report.
The three handover habits
Keep the values exactly as written. The formatter already honours this: identifiers, values and string literals pass through untouched, and only layout and keyword case change. Honour it at your end too. Do not tidy a literal, round a threshold or swap a status code while preparing the handover: the sent query stops being the query behind the report, and the difference surfaces later as a numbers mismatch nobody can explain.
Name the dialect. Dialects differ in syntax, and some of it, like MySQL backticks or T-SQL brackets, only parses correctly in its own dialect. One line in your message, this is the PostgreSQL version, or whatever applies, tells your teammate which database the query targets.
Warn that it was formatted, not re-tested. Formatting cannot break a query, since it changes layout only, but it also cannot prove one. The honest note costs you a sentence: formatted for readability, not run since. Your teammate then knows to execute it themselves before building on it, rather than trusting it as freshly verified.
Limitations to state out loud
The formatter does not connect to any database. It cannot tell you whether the query will run, whether it will return rows, or whether the rows will match the report you sent last week. If the underlying table has changed since the report was produced, the formatted query will show no sign of it. The handover is a readability improvement, not a revalidation, and presenting it as anything more sets your teammate up for a confusing afternoon.
An unfinished statement, or one written in a dialect other than the one selected, may also fail to format; the cause is usually the statement or the selector.
Common mistakes
- Forwarding the raw string to save a minute. The minute is repaid many times over by the recipient, usually with a follow-up message asking where the date filter is.
- Editing values while preparing the handover. Adjusting a literal as you send makes the shared query differ from the one behind the report. Send the original values and let your teammate change them visibly.
- Forgetting to name the dialect. Without it, a teammate on a different database may debug syntax that was never wrong, only foreign.
- Implying the query was freshly tested. Formatted is not verified. Say it was formatted for reading, so the recipient runs it before relying on it.
- Sending only the output. A formatted query with no note about which report it backs, or which values are safe to change, still leaves the recipient guessing.
FAQs
Does formatting change the query I am sending? No. It changes layout and keyword case only. Identifiers, values and string literals are left exactly as written, and the statement the database receives is equivalent.
Why does the dialect matter for a handover? Some syntax, like MySQL backticks or T-SQL brackets, only parses correctly in its own dialect. The tool covers eight dialects, including PostgreSQL, MySQL and SQL Server. Naming yours tells your teammate which database the query was written for.
Can the formatter check that the query still works before I send it? No. The formatter does not connect to any database and cannot tell you whether the query will run or return rows. It was formatted for reading, so your teammate should run it before relying on the output.
Can I format several statements at once? Yes. Paste them together and they are formatted in sequence, separated by blank lines.
Is my SQL uploaded anywhere? No. Formatting runs locally in your browser, which also makes it safe to use with queries that mention internal tables and columns.
Conclusion
The query behind a report is a working document, and it deserves thirty seconds of formatting before it travels. Run it through the SQL Formatter, keep the values untouched, name the dialect, and say plainly that it was formatted rather than re-tested. Your teammate gets a query they can adjust in the first minute instead of decode in the first ten. For the debugging side of the same layout, the companion guide on why formatted SQL helps you spot missing commas and brackets shows what the one-item-per-line shape exposes. The rest of the series lives in the Developer Tools guides archive.