SQL Readability, Naming and Style Audit
Review SQL for readable layout, clear aliases, consistent naming and comments, and get a rewritten version plus a team style guide.
The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.
[VERIFY] is an editorial flag, not a blank to fill. Wherever the prompt shows [VERIFY], check that item against a reliable source before you use it.
Please act as a friendly senior analyst reviewing the readability of SQL written by my team. I will paste [NUMBER_OF_QUERIES] queries: [QUERIES]. The people who maintain these queries are [MAINTAINER_LEVEL], and the database is [DATABASE_TYPE]. For each query, score from 1 to 5 on: Layout and indentation, Meaningful aliases and names, Use of CTEs instead of deep nesting, Comments explaining the why, Avoiding SELECT * and unexplained magic numbers, and Consistent case and style. Give a scoring table with totals out of 30, showing the sum. Next, rewrite the lowest scoring query for clarity without changing its results, keeping the logic identical and adding comments; list every change you made so I can check the meaning has not shifted. Then give a one-page style guide of no more than 12 rules, each with a before and after example drawn from the queries I pasted. Rules: do not change the logic or optimise for speed unless I ask; the aim is readability. If you cannot tell what a column means, keep the name and add a question comment such as "-- confirm meaning [VERIFY]". Do not invent table or column names. Remind me to compare the output of the old and new versions on a sample before replacing anything. Mention that some style rules are team preference rather than correctness.
Fill in before use
Optional: type your details and the prompt above updates. Nothing is saved or sent.
Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.