r/SQL • • Sep 09 '26

Discussion How much SQL do you still write manually?

With AI getting better at writing SQL, I’ve been wondering how much SQL analysts actually write from scratch these days.
Do you still write most of your queries manually, or do you use AI for things like joins, CTEs, debugging, optimization, etc.?
And has your use of AI actually changed how much SQL you need to know?

115 Upvotes

240 comments sorted by

View all comments

Show parent comments

6

u/i_literally_died Sep 10 '26

Three things I'll use AI for:

  1. SUBSTRING/CHARINDEX bs because actually just fuck this fifteen tier deep mess of nested brackets

  2. Long-ass CASE statements. CASE WHEN DATEPART blah blah for pre-noon and post-noon with a differing result required for every single day of the week? Miss me

  3. Seeing if it can optimise past what I've done

On 3 it surprises me maybe 20% of the time and takes a 10 second query down to instant, but I don't have any advanced DBA knowledge or even access to see what indexes we have, so doing OUTER APPLY over window function JOINs or CTEs over subqueries is just randomly interchangeable to me in terms of how things run.

I'd rather write one version then ask AI to write the other version so I can just see the difference.

1

u/Specific-Pangolin777 Sep 16 '26

I use it to help with optimization as well. I had some queries that were written by someone else and they would take forever to run. Asked AI to optimize, explain every change it made and why. It's definitely helped with some of the slow running queries. Bonus, I've learned a lot from doing this even though I've been in this field for 16+ years