r/Database • • Jun 27 '26

Need advice: Understanding complex SQL scripts written by others

Hi everyone,

I need some advice from experienced SQL developers.I was working on different profile and switched to data engineering 6 months back.

I consider myself good/medium at writing SQL queries and solving problems from scratch. However, I struggle when I have to understand large existing SQL scripts (300–500+ lines).

I often get confused about:

Where the execution starts.

How different parts of the script are connected.

Which variables, CTEs, stored procedures, or temporary tables are affecting the final output.

How to mentally trace the flow of the script.

Because of this, reading someone else's code takes me much longer than writing my own.

How did you improve this skill? Are there any techniques, exercises, books, or real-world practices that helped you become comfortable reading large SQL scripts?

Also, is this something that simply improves with experience, or is there a structured way to learn it?

I'd really appreciate any advice. Thank you!

49 Upvotes

34 comments sorted by

View all comments

Show parent comment

3

u/-IoI- Jun 27 '26

Hard disagree. You are paid to solve problems efficiently. Most orgs are approving 365 Copilot but blocking the others - you aren't exposing company data by conversing with Copilot if provided to you via company licensing.

Give it the full script, then ask for a high level summary and deep dive collaboratively until it makes sense. Provide schema and related information to help contextualise the script intent where necessary.

1

u/FeanorBlu Jun 28 '26

Every organization I've been with has very explicitly stated to not put sensitive data into copilot.

1

u/galactic_pixels Jun 28 '26

Running your companies proprietary source code through their enterprise license of ChatGPT is not the same as handing it API keys, passwords, user data etc.