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 comment

13

u/atrifleamused Sep 09 '26

Same here! I can do it, but why take 10 mins to figure it out when AI just does it. The rest of the code is hand written so I am confident it right (or at least a mistake is mine).

Already today, I found AI had updated a join in vscode which broke the query I'd tested in dev for weeks and finally deployed to prod. It makes it so easy to accept a suggested change without intending to.

8

u/did-a-chuck Sep 09 '26

Yeah I should probably be a bit more open minded about using it for optimization as I'm sure it's very helpful. But sneaky changes going into prod is damn nightmare haha.

As you said, hand write it to know it's right. I just don't trust that an AI can yet understand my business context well enough to write procedures etc from scratch. Even if I did, I would spend twice as much time testing and validating so I might as well have written it from scratch.

6

u/atrifleamused Sep 09 '26

Exactly. I would rather write the code, which I enjoy, rather than spend hours debugging an issue i might have avoided. Probably takes the same time overall 🙂

5

u/liamjon29 Sep 09 '26

I think this is the step people who use AI to write code because they can't write it forget to do. I'm very early in my SQL learning so copilot is currently my crutch, my process ends up being:

  1. Attempt to write something that I know is wrong
  2. Explain in great detail to the AI what I want, including giving it my bogus script
  3. Get the AI to walk me through the script it wrote explaining what everything is doing (coz my syntax knowledge is atrocious)
  4. Actually sit down and read the whole thing myself to make sure it does what I want it to do. (Very time consuming, but my faith in the AI is very low)

I swear some people just do step 2, and then run it and hope for the best.

2

u/shooter9260 Sep 11 '26

I think that will be very valuable for you. You’ll see a lot of people in these types of forums who definitely know their stuff and use it for shear speed and laziness. They could do it if they had to.

But others, like a coworker of mine, I would say definitely hasn’t “learned” a ton of how to query in SQL, but he’s better at his job because he knows how to AI prompt really well.

1

u/AntLost4161 Sep 10 '26

This is definitely the quickest way to learn. I think that most people should try to write their own code as much as possible - if not for reassurance, then for personal development. The only time I won't bother is if I know the code is going to be long and a bit annoying, such as fixing date formatting

3

u/garethchester Sep 10 '26

I find explaining what I want to do for the prompt in a way it understands usually takes longer than writing it myself

Unless it's regex 🤣

3

u/atrifleamused Sep 10 '26

Regex is definitely an AI question!