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

5

u/B_Huij Sep 09 '26

Less than I did, but if something is really, really critical, and I need to be able to stand by all the logic decisions and explain my reasoning if challenged on output, I still write it myself. If the problem being solved is really complicated, I still write it myself.

For bug fixes, troubleshooting, simple stuff, etc., I absolutely make Claude Code do it and just review carefully.

I don't want to lose the skill, and frankly I enjoy writing SQL manually. But I have also found that even the latest models of Claude Code get it wrong when things are dicey.

1

u/metric_skeptic Sep 09 '26

this is pretty close to how I see it too. I’m happy to let AI handle the boring stuff, but if I need to explain every logic decision behind a query, I’d rather write that part myself.

31

u/ElHombrePelicano Sep 09 '26

I still write everything 100% myself. The generative AI sql outputs I’ve gotten have been absolutely terrible. Turns a simple 10 line query into a multiple CTE mess.

3

u/metric_skeptic Sep 09 '26

But you can also ask it to find a shorter alternative. Sometimes it comes up with a surprisingly elegant solution that I wouldn’t have thought of myself. I still review the logic, but that’s one of the things I find really useful about AI.

9

u/Ginger-Dumpling Sep 09 '26

As someone who knows a couple dialects pretty well who sometimes uses AI to figure out equivalents/differences when porting over to other DB flavors/versions, I'm regularly presented SQL that is not syntactically valid for the targets I ask about.

I would say that I 95% write everything myself. I'm in an environment where I can't upload schema details, and even if I did, I would probably still have to document all the data anomalies I know I have to deal with before I could remotely consider generating sql from prompts. Pair that with an editor that has templating and auto-complete, I can churn out reliable SQL faster. Stuff that has to be repeated is in views, functions/procedures, materialized in some way, etc.

1

u/RICHUNCLEPENNYBAGS Sep 09 '26

You really want to have a way it can self-verify to iron out that kind of stuff if you want to have AI writing stuff for you. Otherwise it’ll just waste your time.

7

u/ElHombrePelicano Sep 09 '26

Ya, I’ve tried. It’s simply not smarter than me in any way.

0

u/rali3gh Sep 09 '26

Just to say, I wouldn't say it's 'smart' at all. I know this probably sounds pedantic, but I only say it because when I use it, I find I have to keep reminding myself of this.

The more I'm able to approach it as a tool to complement my own 'smarts' rather than mindlessly anthropomorphize it, the more productive I am while using it.

→ More replies (1)

6

u/wirbolwabol Sep 10 '26

I don't need AI to write my CTE messes, I do those all myself!

-2

u/kilopeter Sep 09 '26 edited Sep 09 '26

What models have you tried?

I'd bet good money Opus 4.6 or ChatGPT Terra will nail your 10-line query given the same context you use to.

I hate job displacement as much as the next SQL wiz, but you're delusional or inexperienced if you think modern AI can't oneshot any given 10-line query.

4

u/ElHombrePelicano Sep 09 '26

Who are you people? Yes, I’ve tried both of these models and they do not come anywhere close to instilling the sort of confidence y’all have in them. I would be terrified to have y’all executing anything in my prod environments.

→ More replies (7)

0

u/dbrown122 Sep 09 '26

Idk what AI you are using, but I have not found that to be the case, my job has SQL Authoring skills and it churns out some decent SQL. That being said, I am more cautious and only recently started to see what it can do.

-4

u/elevarq Sep 09 '26

This sounds like a problem with the input, that results in bad output

7

u/ElHombrePelicano Sep 09 '26

Wow……. 🤯 why didn’t I ever think of that? /s

→ More replies (6)

17

u/totallykindofnormal Sep 09 '26

At this point, I have AI doing the majority of the development work, and it’s my responsibility to do peer review and make sure that the output matches requirements. You’re doing yourself a disservice if you don’t use AI to speed up your coding, but you shouldn’t push anything without verifying the output.

2

u/Jacob_OldStorm Sep 10 '26

So how do you verify the output? Write the query yourself? Or do you mean you verify the output of the prompt, not the output of the query. Man I would hate that, I already hate everyone else's queries, don't need more of those :p

310

u/did-a-chuck Sep 09 '26

98% myself. I use AI when I don't want to figure out some horrible string extraction problem.

30

u/feignapathy Sep 09 '26

I'm along a similar vein. 

Write just about everything manually, but will open up an AI prompt for something annoying here and there.

1

u/RavenCallsCrows Sep 11 '26

Yup, same. And the occasional 'oh, crap, I haven't done this in a long time, how does the syntax go for it in %current_SQL_db%' when bouncing amongst diverse databases.

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!

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

3

u/rbobby Sep 09 '26

some horrible string extraction problem

I have a new best friend. Thanks I never even considered it for that.

2

u/silverlightarmada Sep 09 '26

Yes, same, except I also use it for relative date code because it’s never really absorbed into my brain properly.

I like writing SQL, I generally don’t really want AI to do it for me (and it’s kinda bad at it a lot of the time too)

2

u/GeauxCup Sep 10 '26

Same. Id rather write it myself than spend 3x that long checking that ai caught all the nuances of our systems.

2

u/da_chicken Sep 10 '26

Same, but with the obnoxious XML/JSON manipulation.

2

u/peccator2000 Sep 10 '26

Whoever came up with putting and manipulating XML or JSON in a relational database needs to have his access rights taken away.

2

u/Outrageous_Let5743 Sep 13 '26

JSON is fine. Postgres can perfectly deal with it and can even index json data. XML is just horrible. I had to redo everything what a data consultant did help with data extration. He choose xml (while json was available) and he could not correctly parse xml in sql server. so it contained a lot of | or || or | | in his final table.

1

u/peccator2000 Sep 13 '26

I know Postgres can do it and many use it. Haha yeah, XML with text manipulation must have been a nightmare.

1

u/LinksLibertyCap Sep 09 '26

Yep.

Fractional headcount weighting for scheduling dashboards was my latest one.

1

u/db-mechanic Sep 12 '26

Likewise, I write 98% of my own SQL and I also write sql notes from books i like.

1

u/beginnerTA Sep 22 '26

How do you ensure that you’re not giving away your code to AI when you do use it?

1

u/did-a-chuck Sep 22 '26

You don't! But it's nothing business sensitive

129

u/Jon-Robb Sep 09 '26 • Bravo

I don't even write my -- reddit posts

11

u/The_Chief Sep 09 '26

If AI starts double dashing -- I'm done for

4

u/carlosf0527 Sep 10 '26

Openclaw agent here. I will review your agent's posts and send you dm's with improvements.

1

u/DPool34 Sep 10 '26

I get it! 😂

34

u/Content-Parking-621 Sep 09 '26

Still write core query logic manually since you need to know what correct output looks like before trusting AI's version, but joins boilerplate and debugging syntax errors, letting AI handle those saves real time.

→ More replies (4)

128

u/BrupieD Sep 09 '26

AI requires way too much context to understand my goals from my company's db. By the time I've filled in enough of my requirements for AI to be successful, I can just write the SQL myself.

I do a lot of ad hoc query writing that is often not very complicated. I've already internalized enough table and appropriate join information about those tables. SQL seems like the least helpful thing AI can do for me.

10

u/rbobby Sep 09 '26

SQL seems like the least helpful thing AI can do for me.

I concur, but buddy above mentioned narly string extractions and having done those, and passed at least one on after giving up, I am definitely gonna try next time.

7

u/kilopeter Sep 09 '26

Out of curiosity, what makes you think AI can't absorb your particular context and goals? What models have you actually tested this assumption with?

21

u/BrupieD Sep 09 '26

I didn't say I don't think it can't absorb it, I simply don't want to write 5 lines of prompt to write a 4-line query.

9

u/j48u Sep 09 '26

This seems risky considering how anti AI the responses are so far, but that's a solved problem. If the AI has access to your table structures, you only need to give it the business context once. A few back and forth describing novel scenarios and you might end up writing 100 lines once, then a single sentence prompt anytime in the future will get you between one and infinity lines of SQL until the end of time. And yes, it will be optimized in any way you want it to be.

The only reason I bring this up is that it's honestly a disservice to people in this field to pretend AI hasn't gotten exponentially better every few months for the past few years. Most people who are not able to use AI properly are not going to have a job in 5 years, unfortunately.

4

u/DharmaPolice Sep 09 '26 edited Sep 09 '26

I think there's a feeling that if it's getting "exponentially better" every few months, is there even much point learning the foibles of today's models when in a few months there'll be a new set of foibles to work around / with when the "exponentially better" model will be out? (And if it really is improving at that rate and that somehow continues indefinitely - which feels unlikely by the way - then it's almost irrelevant what we use now since the tools we'll have in two/three years will make current tools look like banging rocks together.)

I know AI proponents like to get excited about how fast things change, but from an investment of time and energy you need some kind of platform stability. Would you learn a programming language or use a platform that changed dramatically every few months? I browse HackerNews which is fully onboard the hype train and some of the discussions there almost seem like self-parody - "I have this problem, I'm using XYZ which came out three months ago" and someone will unironically reply "Why are you using such an old version? Everyone's moved onto ABC which came out last week."

This is especially true when actually writing new queries is often a fairly small part of a lot of people's jobs. Don't get me wrong, I do use AI tools daily but a lot of the stuff I read is "We've made the easy part of your job even easier". Yeah, that's great and all but not really that helpful.

If you find writing SQL is difficult or time consuming then sure, I can imagine it must be a huge timesaver.

2

u/BplusHuman Sep 10 '26

I have good news for you... You never really needed to hit enter. It can all be one line of query

3

u/geek180 Sep 09 '26

It sounds like you’re still using a pre-agentic era AI setup from 1+ years ago. There’s a lot of ways to document your projects / repositories such that you never have to re-explain anything to the AI.

For me, I just have Claude read an existing ticket (also written by AI), or I just type out any instruction, then it spins up an agent in a new worktree and then just… does the work, usually by delegating individual tasks to sub-agents.

Some tasks just have to be handled manually, often admin duties, but for most work I’m just handing tasks to small swarms of agents and nudging them in the right direction as-needed.

1

u/kilopeter Sep 09 '26

What about your 200-line queries?

→ More replies (10)

2

u/did-a-chuck Sep 09 '26

Are there any you would recommend? I am quite set in my ways and deeply skeptical that any model can fully "understand" my business context...but I want to remain open minded.

5

u/geek180 Sep 09 '26

You’d really be surprised how well current models can understand complex business operations and tech stacks. At this point, Claude probably has a better grasp of our whole tech system better than any one person.

1

u/rali3gh Sep 09 '26

I'm fairly sure an MCP server setup can serve as a 'translation layer', so to speak, giving an AI a retrievable understanding of data structure and the business-side employees contexrual understanding of what it all actually means day-to-day.

It takes time upfront to construct and configure, but would save time on the backend if you are asking the LLM to generate a lot of queries.

All that being said, I personally rely more heavily on AI for early investigation and analysis of my hypothesis and then less as I near the end goal of my work/project. So, your mileage may vary, as they say.

1

u/CalebAsimov Sep 09 '26

Yeah, it's literally so easy to write queries, like damn, way to take away the only thing that lets me rest my brain for a few minutes.

1

u/mooslar Sep 10 '26

In the codex app, you can select a folder/directory where it can read and write files. You can put a markdown file in the root of that folder and it will read it at the start of every chat.

I manually made a good size mark down, then told it to scan all of my saved queries and csv dumps and blow out a copy with what it thinks it can expand on. I read through everything it generated and made some change and now i have this huge corpus. I also add style preferences

I can treat it like a junior and ask it for basic queries and procs and it nails it most times.

1

u/Few-Spot1905 Sep 11 '26

sounds like bad AI usage tbh

if the ai can write correct SQL with the right context but has trouble repeatedly retrieving it by itself, this is exactly what a skill is for

you prompt it until it gets it right then ask "hey can you write me a skill so next time you can just get this right the first time?"

then the next time you ask it to query it loads the skill and just gets it right

I'm the grand scheme of things SQL isn't that hard and LLMs are pretty good at it

-5

u/elevarq Sep 09 '26

The challenge isn’t giving AI enough context. It’s giving it the right context, and knowing which conclusions can be established without business context.

27

u/Eire_espresso Sep 09 '26

I tried it for a while but I lost touch with my queries. When you write them they are mapped into my brain. Generated queries made me feel I was parsing someone else's code, which I hate.

Now I just use AI for formatting and documentation and the odd performance recommendation

7

u/Deep-Internet1316 Sep 09 '26

Agreed. OP might as well ask if we still read books or if we just ask AI to summarize it.

Like if AI does it, then what was the point? I'm here to understand the thing and take ownership, not pretend I understand it while secretly passing notes back and forth with my really smart friend.

4

u/Gm24513 Sep 09 '26

If you do sql with AI you're just begging to get fired or worse.

5

u/stormmagedondame Sep 09 '26

Absolutely in my office we have a lot extremely sensitive data in our databases. Linking or uploading anything to AI is a really fast way to get fired and become unemployable due to violating a NDA/DUA.

1

u/outlier_fallen Sep 11 '26

Most large companies are hosting their own instances so the data never leaves their ecosystem. Is your company not doing that?

1

u/Gm24513 Sep 09 '26

Yeah I had a genius a couple days ago asking for some work to be done for them and suggested uploading the dataset as a table to chat gpt to make an append and update in Microsoft access. Absolute atrocity.

-4

u/metric_skeptic Sep 09 '26

I don’t really agree with that. If you use AI properly, it can make the boring parts of the job much faster and free up time for more interesting work. You can spend that time on better analysis, more ideas, or just taking on things you wouldn’t have had time for before.

4

u/Gm24513 Sep 09 '26

You don't have to agree. If you use AI for SQL you're a fucking moron

5

u/AhBeinCestCa Sep 09 '26

I agree 😂. Bro prolly never worked in a company and just try to justify his « vibe coding ». SQL is more easy than prompt engineering

0

u/metric_skeptic Sep 09 '26

Don’t become so nervous just keep writing your SQL 😊

-2

u/Gm24513 Sep 09 '26

Go ahead and delete prod data because you fucked up the one time you didn't worry about double checking.

2

u/metric_skeptic Sep 09 '26

Why do you think that people who use AI don’t double check or correct its answers? Don’t take it so personally. It’s just a discussion

→ More replies (1)
→ More replies (1)

1

u/CascadeDuck01 Sep 09 '26

Why do you say that? It can be useful as a tool, not a crutch. Anything that helps you work more efficiently shouldn't be snubbed in my opinion.

10

u/bigeyez Sep 09 '26

The vast majority myself since I work with protected data. I will get frameworks from AI or use it for things like making regex or when I forget syntax for things.

18

u/UncleJoshPDX Sep 09 '26

My job has too much riding on it to trust a machine to make something up.

-1

u/vision666 Sep 09 '26

could you explain the stakes a little bit?

4

u/machomanrandysandwch Sep 10 '26

Not OP but I work some projects that deliver north of $40M in payments and include things like sending credit bureaus data that impacts people’s credits; those are really high stakes. ANY variances from our approved rounding methodologies, missed accounts, misapplied payments, anything that an auditor can find that leads to a correction can cost me My job at all times. It’s incredibly stressful, the timelines are nearly impossible, and they basically hang our jobs over our head. I have to defend my code and design logic constantly, so I may use AI for some help but o better be absolutely sure my code is doing exactly what it’s supposed to be doing.

5

u/UncleJoshPDX Sep 09 '26

Multi-billion dollar business. I have to ensure 1,400 sales reps have the correct accounts or people don't get paid. I'm not risking any of that to a digital hallucination.

9

u/AhBeinCestCa Sep 09 '26

It’s easier to write SQL than it is to write prompt. I use AI for questions like « is it more performant to use an unpivot or multiple UNION ALL select » ect

7

u/Slitty_sam Sep 09 '26

95%+ It takes longer to describe a situation and context and what I need and where from etc etc to an AI than it does to just write the query myself. The other 5% is when a query gets too complicated or I'm unsure of the syntax of the thing I know is possible but don't remember exactly how to do.

6

u/GlockByte Sep 09 '26

All of it

2

u/Accomplished-Dig8753 Sep 09 '26

I draft anything complex myself then throw it at Claude for code review (it's great at catching typos and missing where clauses). Then I review the output and edit as necessary.

0

u/metric_skeptic Sep 09 '26

I do the same

19

u/VulcanRugby Sep 09 '26

Maybe 10% of what I wrote even 3-4 years ago. For complex querying, I'm still using AI to build a base and then I'm maneuvering specific pieces of logic around. Claude has all the documentation necessary to get a query off the ground, and I'll drive it the final mile.

5

u/Rodyadostoevsky Sep 09 '26

I would say a little more than half? AI is really good at writing/optimizing queries. But it doesn’t have the context of the business/business rules and the data. So I think I’ll be writing majority of my queries myself for sometime.

Writing queries from scratch is also part of my thinking process. So I prefer to do it. Sometimes I would then dump the quer(y)ies in Claude and get it to write it properly.

4

u/Soccermom233 Sep 09 '26

I use it for help around concepts and syntax but typically write it myself.

7

u/Reach_Reclaimer Sep 09 '26

Why would anyone need to use AI for some of these things?

8

u/elevarq Sep 09 '26

Close to zero percent. And every time I have to, I spend time on my templates to make sure AI can do it for next time just as good

3

u/gumnos Sep 09 '26

for what definition of "write manually"?

100% of my code by hand, and 0% AI, but a small percentage of it takes advantage of Intellisense-style tab-completion, so I suppose I'm not technically "writing" that. 🤷

3

u/IrquiM MS SQL/SSAS Sep 09 '26

Most, by far

3

u/lalaluna05 Sep 09 '26

I write all of it. Sometimes I forget syntax or how to apply some things and I’ll ask for help, but I don’t like AI writing my code. The code I’ve reviewed that HAS been written by AI was needlessly complex and/or inefficient.

3

u/Count_McCracker Sep 09 '26

If I do it’s a simple select where statement. I haven’t written complex sql in a year or so. It’s a blessing and a curse

3

u/Aggressive-Dealer426 Sep 09 '26

Still, all of it however, if i get a weird result set or edge cases issue. I'll paste what I've written to see if I did something stupid that I'm not readily seeing.

AI Coding is abysmal, I spent more time telling it where it is wrong and to" fix it" that it fixes it, but breaks what is already working, and it just goes down this doom loop it never recovers to provide an actual fully functional SQL or any other language code

3

u/DaOgDuneamouse Sep 09 '26

I write everything myself. If there's anything I don't remember the syntax for, I google it. My users ask complex questions. If I were to try to setup all that meta data, it would take longer than just writing the query.

5

u/Thiondar ORACLE Sep 09 '26

All

2

u/Eleventhousand Sep 09 '26

90%.

Has it changed how much I need to know? I don't know. I already know most of it, since I've been writing it every day for 25 years. However, when using proprietary functions in different DBMS, AI doesn't decrease "what I need to know," because I'd have to look that up anyways.

2

u/BarfingOnMyFace Sep 09 '26 edited Sep 09 '26

quite a bit. but I also write quite a bit with AI, too. It's smart to write by hand to keep familiarity and comfortable with the code. In particular, if its new concepts, or an RDBMS I'm not intimately familiar with, I will definitely write stuff by hand to ingrain it in my brain. And then, yes, 100%, AI for sure, once I have a base model done on my own, and then have AI build out triggers, funcs, views, etc, run performance tests on assumptions to remove assumptions in under a few minutes, versus a chunk of my day. I'll have it write that SQL till the cows come home. But I'm always the peer reviewer if AI is writing code. I never let a line slip that I cannot read or fathom what it is doing.

Edit to add: In very complex scenarios, I'll tend to ignore AI entirely. It can lead people astray as it tends to not receive nor properly handle the significant context it needs to solve complex scenarios. Healthcare systems and the very complex queries within them come to mind...

2

u/Reading-Comments-352 Sep 09 '26

The AI has to be checked and rewritten. So it depends on whether someone wants to just write it first to avoid spending more time fixing AI code.

2

u/Latentius Sep 09 '26

Pretty much 100% is hand-written still, though I might use AI as interactive documentation if I need help with syntax for some function I rarely use.

AI simply doesn't have the context to understand how the data all relates and what it actually means. There's virtually no existing documentation on the data so you'd need to manually write a complete novel just to give AI the proper understanding, and ain't no one got time for that.

2

u/geek180 Sep 10 '26

I built a semantic layer (metadata catalog of all tables, columns, metric definitions, etc) into a vector search, surfaced via an MCP server.

Now Claude can understand our entire data catalog. I initially made it to fulfill certain kinds of analytics inquiries we get, but it’s also great for allowing the AI to quickly understand the relevant parts of the database when doing development work.

1

u/Jaded_Spray_6855 Sep 10 '26

hmm this seems like the generic fix nowadays. are there any downsides to this solution that you've faced so far?

2

u/Indyy Sep 09 '26

I have always found AI to be the best for analytics with logs/errors, and then *maybe* creating a framework/template for whatever it is I'm working on. Context is so difficult with LLMs that I often end up with something way over engineered for the problem or task at hand.

2

u/Gabbiani Sep 09 '26

I will use it to validate my work for context or to look for possible gaps but I write it myself.

The code that AI produces is fine for non-complex things but it fails miserably when I’m trying to use it to do work for me.

2

u/Guilty-Property Sep 09 '26

0% I use my keyboard

2

u/Prownilo Sep 09 '26

Depends, I generally write what I want then ask ai what it thinks, 9 out of 10 times if will turn a simple query into a huge thing that way over complicates things, but every so often it has good idea that I incorporate into my solution, or reminds me of a method I forgot about.

I try to use it as tool to keep my game up rather then let it just do my job for me.

2

u/phesago Sep 09 '26

i would say about 70/30, depending on the task at hand. I use projects and customizations alot in claude, and i use the template explorer in SSMS as well.... not to mention my massive one note with other templates I save for certain problems or techniques that I ought to remember... but only so much "gets written to disc" these days and im getting older. I would rather outsource my memory to tools and save the grey matter for the critical thinking.

The thing with AI though is its supposed to be a time save, right? So use it for the things that will save you time. Since I dabble in to the data engineering space, I am often asked to interact with technologies I know absolutely nothing about. AI helps me get up to speed to get tasks done, or get more proficient with technologies I end using more and more. One example is powershell - never really used it tll the past couple of years and now I end up using almost daily.

2

u/jrblockquote Sep 10 '26

80%. Just wrote a fairly complicated proc using it and it worked great. Described the problem section by section and iterated. Probably saved a day or two.

2

u/peccator2000 Sep 10 '26

If I have a choice, I will write it myself. ORMs suck.

2

u/cwjinc Sep 24 '26

100%
The only time I use AI is to form regular expressions when I need to use one. AIs are very good at that.
I just have them produce the formula, and put it in the SQL myself.

4

u/Kryddersild Sep 09 '26

Just how complicated is your sql to need AI for it.

3

u/HustlaOfCultcha Sep 09 '26

I hardly write any these days. I still look at the finished product to make sure that I'm getting what is needed. If it's something really simple that I can do in a jiffy and would take me less time than to use AI to get the answer, yeah (sorta like doing a VLOOKUP or SUMIF in Excel where I've done it by heart so many times I can write one up faster than I can ask AI for it). But since more of my queries/subqueries/joins are pretty complex...I can write them manually, but AI is usually much faster.

But I tell all junior analysts...you do need to know how to write these things manually so you can understand what AI has written and to check for errors. AI is good, but it still makes way too many errors for any data analyst.

2

u/GTS_84 Sep 09 '26

100%

And I'm not anti AI or anything (I am anti AI for art, but not code), I use it all the time for other languages. JavaScript, R, Powershell, bring on the AI.

But for SQL I just find that I'm still faster doing it manually.

2

u/ShoreWhyNot Sep 09 '26

Writing a query and realizing I’d prefer a part of it to be joined as a CTE instead, it’s (mostly) pretty good at doing that quickly for me, saves me some time after looking it over to ensure it didn’t hallucinate something

2

u/BplusHuman Sep 09 '26

If Portuguese is your fluent second language, you don't need to run EVERYTHING by a translator first, edit it, then submit. That's an inefficient process. If you are bad at Portuguese, it gets you a refined product faster, but you still are bad at Portuguese.

2

u/wdm006 Sep 09 '26

I still write the shape by hand. AI is fine for the boring join boilerplate once I know the grain and the filters. If I can't explain the query without the model, I don't ship it.

2

u/travgt01 Sep 09 '26

0%. Claude code does it all. I get done with jira tickets that would take me weeks in hours.

0

u/PickledDildosSourSex Sep 09 '26

Ditto. I've ditched manual SQL and moved to spending the time managing definitions, business logic, etc, as well as setting up some unit tests to make sure drift isn't occurring. It depends on use cases--if i'm doing accounting reporting, that's different from napkin math estimates--but wow does it save me SO much time.

1

u/Either-Surprise6390 26d ago

99% First, I don't need it. I might on rare occasion ask it how it might do something for considering other options. Second, I look at database tables, fields, relationships, etc... as proprietary information and I wouldn't provide that to an AI. So, it really doesn't know the structures involved to really give me anything useful. Now if the software is something I'm building for myself, then I could share it, but in my day to day job I'm managing systems that I don't own. Even in that situation I'd still be writing 95-99% of the SQL.

Also, I do not like CTEs and never use them. Debugging, I usually figure it out myself and again, that would require delivering proprietary information and I wouldn't do that.

1

u/postnick Sep 09 '26

I keep good samples and example code so I parse together most of it manually. I do let AI help me when it’s super complex. Or like others have said when I have trouble on one string extract.

I’ve been asking more for help optimizing if I should join or CTE or how I should index or write my where clauses.

1

u/That0n3Guy77 Sep 09 '26

Depends on how complex the thing I want is. I will often weight some starter logic for what I want the query to do then have it modify and make it complex. Seems to work really well and saves me like 75% of the time of typing EVERYTHING out myself

1

u/amayle1 Sep 09 '26

SQL is already kind of at the abstraction level where you just write what you want. Yeah I can write in English but SQL is already kind of that.

I do use it to edit things, like if I wanted to switch from a sub query to a CTE, or if I’m adding another aggregate and want to move both aggregates to lateral joins or something. That definitely saves a few keystrokes.

1

u/timusw Sep 09 '26

~90%. i'm in a big enough org that all context is maintained in a repo and agent just reads it.

1

u/ddBuddha Sep 09 '26

I know the stuff I work with well enough that I write any sql I use for work myself most of the time. I use AI a ton for other stuff though.

Well actually that’s true for MSSQL, but I keep forgetting we are using Postgres for a few things now. I’ll still write a lot of the queries I’ll use on those dbs but I have had Claude help put a tool together to handle migrating row level data between different Postgres instances and handle things like re-iding records if needed due to conflicts between the two.

1

u/NawMean2016 Sep 09 '26

I use it a lot to debug and optimize. I have ways of doing things, but I like to stay curious so I'll sometime poke AI to see if there's a better way of writing a certain script, ask why it's better, etc etc.

1

u/National_Cod9546 Sep 09 '26

Now that I'm out of tokens for the month, all of it. 

1

u/HeyItsRed Sep 09 '26

My org is trying to heavily push ai for self-service reporting. Part of my job is to test the models’ ability to generate code/results.

I write maybe 25% of my queries. I’m not an analyst though so that’s part of it.

I spend a good bit of time trying to optimize context layers for the models via RAG, skills, etc.. It’s more work but it makes higher quality results for end users.

1

u/Dazzling-Address6115 Sep 09 '26

I write everything myself. My personal distaste for AI aside, I couldn’t use it for the gov databases I work in anyways.

1

u/pi3volution Sep 09 '26

Maybe 10% manually. Not by choice. AI means high productivity becomes the norm.

1

u/lez_s Sep 09 '26

This new company I’m at is all about using AI. Before this current role I felt I had time to workout any issues and try ideas out.

Now I feel I need to get the basics done and put it into copilot for it to finish it off, review it then make a view for a report.

I miss the days of feeling like i achieved something.

1

u/dgillz Sep 09 '26

Almost all of it. AI does not know which tables and fields I need, nor how the tables are related. How do you do this?

1

u/Ambitious-Tear-9436 Sep 09 '26

I would consider myself an expert in SQL, but it has been a while professionally having to write direct SQL queries. But having that knowledge lets me call out AI, and its use of ORMs and fix the issues before they become a problem.

1

u/DharmaPolice Sep 09 '26

95% of it. I don't spend enough time writing SQL queries on a stable platform for an investment of time/energy/focus to be worth it. Even if I could write SQL 100x faster that wouldn't ultimately save me much time in the overall context of my job.

1

u/cafealpha82 Sep 09 '26

100% but i let ai to document my script. Once i asked to say its opinion about my scripts. Ai said something good then i asked to be frank. Then i removed the app

1

u/OO_Ben Postgres - Retail Analytics Sep 10 '26

All of it unless I get stuck on something lol

1

u/min_mus Sep 10 '26

Almost all of it. 

1

u/fruitstanddev Sep 10 '26

Pretty manual still. However we are doing a lot of work to bridge our knowledge graph with our dbs so Claude can build queries correctly. It does a pretty good job at the basic questions. Topics that are very complex that are hardly defined needs a data analyst.

1

u/PalpitationKind8854 Sep 10 '26

Id always write from scratch. AI cannot do a better logic job than myself lol

1

u/Snackson_Heaves Sep 10 '26

I use Ai to reverse engineer a command written by someone else. I also use it to remove aliases for documentation and upkeep.

1

u/Tigri2020 Sep 10 '26

Still like 90% AI has been a great assistant to optimize my queries tho but most is manual typing

1

u/jamiesray Sep 10 '26

All of my sql is from clause

1

u/ArielCoding Sep 10 '26

I write the logic myself, but let AI handle the syntax stuff like window functions or regex. The important skill now is knowing enough SQL to catch when AI gets it subtly wrong.

1

u/Doaner Sep 10 '26

Honest answer 0. I bet I’ll get some hate for this but it’s the truth.

Well that’s not 100% accurate. If AI doesn’t get it right I will write part of the code as the prompt. I have enough rules/skills that this doesn’t happen often enough to even worry about. It knows all of my current business processes and can find the answer faster than I can. Also I turn a lot of my queries into apps or skills for other people so it’s good to make sure AI can do the query right before the hand offs.

1

u/RandomiseUsr0 Sep 10 '26

Vast majority of- have several LLM helpers but would take longer to explain than to simply walk the data myself

1

u/bingbongpeepee Sep 10 '26 edited Sep 10 '26

as a data engineer that is more python-heavy, 100% AI lol

1

u/wirbolwabol Sep 10 '26

I write all from scratch and I actually enjoy it. It's a puzzle to solve when trying to eek all of the speed out of a query. So everything CTE's,optimizing, Joins debugging.

1

u/witchcrap Sep 10 '26

In my current job, I write 99% of the queries I use. It's a start-up, so we don't have AI subscription. I use generic AI for some tweaks here and there especially for really long queries.

HOWEVER!

My previous job was much more pro-AI. REALLY, really pro-AI. One of the brilliant minds there created an AI agent that you can feed your SQL queries, and it will spit out an "optimized version" to preserve quality while increasing performance.

It was required.

Every single time that you will use an SQL query, you have to use that blasted agent.

It made my lose my mind.

I still have no idea how they were enforcing that, but they keep raising the "low number of usages in AI", so I just had to play long.

1

u/trader_dennis Sep 10 '26

Been using it for any regular expressions for years.

I've been typing in requirements lately. Gemini is pretty amazing when you are working in Big Query.

1

u/dragonfly_bowler Sep 10 '26

I've used AI to rewrite some messy queries that I had to modify. Mostly queries that previous developers wrote using the sql designer, so they were loaded with a mix of left and right joins. I asked AI to convert to all left joins because I find LOJs easier to maintain. The queries that AI returned gave me different results than the original, so AI is not perfect. I was able to rewrite them as LOJs manually with a little more effort.

1

u/mkt853 Sep 10 '26

all of it

1

u/geek180 Sep 10 '26

Basically all my code is written by AI. There’s a lot of skeptics in this thread, but I genuinely just don’t think a lot of people have really experienced how good AI has gotten at doing this stuff.

Handwritten code will be largely gone within a year or two and the only reason it won’t be sooner is because people are slow to learn and trust this stuff.

1

u/Tricky_Tart_8217 Sep 10 '26

Holy shit. You guys in this thread are in complete delusion and are going to be passed up by younger people soon if you don't adapt.

Try coco in snowflake, it's very powerful and it solves a lot of the context problem 

1

u/Zestyclose-Turn-3576 Sep 10 '26

No AI at all. I've not found a benefit.

1

u/ThisIsFun- Sep 10 '26

95% of my SQL is done through AI, specifically Genie Code. given it has governed access to my data, it usually makes a really good first pass, with me reading most of it but this is ever decreasing

1

u/naciches_ Sep 10 '26

Mostly manual. I use dbForge AI Assistant when I’m stuck or need a query explained, but I still check everything myself before running it.

1

u/Heiden133 Sep 10 '26

More or less 0. I have MCP which holds a knowledge about the database in semantic layer. AI still of course makes mistakes, but these mistakes can be then indexed in knowledge base, and it’s often faster to prompt again.
Still, I don’t trust it before I read and understand it.

1

u/carlosf0527 Sep 10 '26

100 percent. To be honest, I think it takes longer to describe what I want in a query than to write it myself. I think, as well, one of the issues is that you have to understand the data in the tables for the generated code to be correct.

I have used it to fix weird issues on really large queries, though, but this is rare.

Note - not a luddite - I use code generation for other languages.

1

u/FreedToRoam Sep 10 '26

I write everything manually. If I needed my lines to quadruple I'd ask AI to rewrite my code ;-) ... anyway I think I would consider AI if I needed to write some complicated CUBES ... thankfully I have not had to do that in 10 years.

1

u/Anon2148 Sep 10 '26

I’m going to say 70%. I’m still new and unsure many of the syntax, so I always use AI to make a base. Afterwards I can pretty much understand what’s it doing and will adjust it to my needs.

1

u/Illestbillis Sep 10 '26

We have an enterprise license and it works like a sandbox. I made a project and uploaded the db schema to it. Now I just have to ask it to build a query and it does. It is a major time saver. There is not much that I have to code for manually anymore.

Edit: this is mostly for read only queries unless I am in a pre production environment.

1

u/shougaze Sep 10 '26

All of it

1

u/Wuthering_depths Sep 10 '26

All of it. Don't really do super complex queries like those used in reports all that often, more simpler multi-step integrations. I have a lot of saved SQL that I reuse.

I suppose I do use some AI if google results count, especially for Python which I'm learning now. I won't learn shit if I let Cursor or some other llm do all of it though. I have 2 maybe 3 years before I retire so I don't have any urgency about learning this stuff to be one of the few left working in the years ahead.

Edit: as others are saying, for some nasty string manipulation logic or crazy regex, definitely I'd welcome some bot's help :)

1

u/BetterLearnComputers Sep 10 '26

I still wrote it mostly myself because I can just type what I'm needing but sometimes I like to throw my SQL into Copilot to see other ways that may not always cross my mind. It's fun to compare but I get to nervous I'll lose my edge if I use AI to much

1

u/Codeman119 Sep 10 '26

For just SQL development 98% if it’s just writing for research and generating reports. Because tables and relationships can be complex if they are not done right. And honestly when you are under pressure to get something done you don’t always follow standards to get it done.

Now when I start a AI project that I am building an app with SQL involved then it 98% AI written.

Just depends on what I am doing.

1

u/Efficient-Editor-242 Sep 10 '26

I work in digital forensics. Sometimes when I can't find something, digging into a db helps me find it.

Outside of that, what are the real world needs in using it? I love it, don't get me wrong, I just can't wrap my head around who/what is using large databases.

1

u/singletWarrior Sep 10 '26

It doesn’t have enough context to write good queries… good AI operators know how much context to show it to get good enough output

1

u/alex1033 Sep 10 '26

We don’t have time to write SQL anymore. Busy troubleshooting AI’s SQL.

1

u/hunpriest Sep 10 '26

Almost none. I have typed enough. Let's the slave - I mean LLM do it.

1

u/rita_fires_nhis Sep 10 '26

99% manually. Our internal AI tools hallucinate table names and columns like a motherfucker. If I have an error somewhere that takes me longer than 10 minutes to find I’ll use AI to help find it

1

u/KatFromSisense Sep 10 '26

I couldn't really put a percentage on it, but one thing I use AI for is taking a query that's already written and trying to break the result. Nulls, duplicate rows, weird join grain, boundary dates. It can come up with useful tests, but you still need enough SQL to tell whether any of it makes sense.

1

u/Buffylvr Sep 10 '26

None, sql is terrible

1

u/sfnmoll Sep 10 '26

after setting up skills in claude for doing modelling and syntax the way our team preferred, it has decreased to a minimum... work in investment management

1

u/NoEggs2025 Sep 10 '26

Once AI starts doing CTE’s and nested tables I going to start flipping burgers

1

u/jwk6 Sep 11 '26

All the SQL.

1

u/cccadet Sep 11 '26

Most of it. Autocomplete handles names and syntax, while I mainly use AI for unfamiliar vendor-specific syntax or to suggest alternative approaches.

The part AI can’t own is correctness: business rules, null behavior, cardinality, permissions, and query cost. If I use generated SQL, I still read every line, test it with representative data, compare row counts, and inspect the execution plan before production.

So AI has reduced lookup time, but it hasn’t reduced how much SQL I need to understand.

1

u/andreidorutudose Sep 11 '26

I only write small selects by hand. I don't have the patience anymore to write, I do read a lot of code and ask questions though

1

u/rosentmoh Sep 11 '26

I write 100% of my SQLAlchemy code manually.

1

u/Murky-Pianist3960 Sep 12 '26

Most if it… AI is pretty terrible at writing good SQL…

1

u/scbywrx Sep 13 '26

Man, I love a good thousand-line CTE like everybody else, but I disagree with everybody saying AI can't write queries. AI can write a query. It depends on the context.

Up until about 8 months ago, all I did was handwrite queries. I was called a human SQL compiler by more than my colleagues. When it comes down to having a full corpus of SQL statements that are vetted, and you have an AI that's working within your toolset, and you know how to prompt it properly, you do not have to do hard coding any longer. You become your own QA.

It's the corpus of vetted queries, simple to extremely complex. If you have a corpus that is within that project that you're writing a query for, it's great. Now, step back: if I'm doing ad hoc work, I'm back to writing my own queries.

1

u/Glum_Cheesecake9859 Sep 13 '26 edited Sep 13 '26

0% - Most of our SQL is mundane. Nothing that Claude cannot figure out now. I have been writing same level of SQL for the last 10-15 years and I have nothing else to prove manually writing it when the employer provides a free subscription to me.

1

u/thequerylab Sep 14 '26

Would say 50 - 50. By trusting solely on AI, it gives too many lines with some junk peice of code which is really not necessary but it really helps in debugging issue.

1

u/dkh1871 Sep 14 '26

Honestly, I can write a query faster then it takes to explain to AI. Granted I've been use SQL for years around 10 or so years and know my datasets pretty well.

1

u/Complete-Ebb-1035 Sep 14 '26

In general, I have found "AI" to poorly understand joins. Some tools can describe existing database tables with multiple existing joins. But IME no AI tool can generate tables and related joins for complex relationships. If you build a skill file that explains exactly what you want, you might get good approximations on which you can build. But once you've composed a skills documents, you've done most of the work.

1

u/This-Emergency8839 Sep 21 '26

It's slower using AI for the complex stuff. By the time I've explained what I need and prompted it a dozen times, I could've spun it up myself.

I've also seen some horrendous queries written by AI to deduplicate a rogue table which filled up the log file, had to be rolled back, and nearly took our server out while it unwound for 17 hours. 100 million rows in a single transaction and no batching? No problem!

I do use it to tune old queries and optimise indexing if there's a mess of crap on a table, but I prefer to hand code new queries.

My role of thumb is new logic: do it yourself. Established logic, let AI have a go. At least you can benchmark the results against a working example.

1

u/Correct_Method_3963 Sep 21 '26

I have been in the profession for almost 20 years. AI has been writing literally everything for me lately, I am very lazy. The thing is that I know in advance what I want to get, what kind of structure or what sequence of actions. If I see that AI wrote not what I want, I adjust the prompt. It turns out much faster than writing it myself. Especially since I often have to write identical structures simultaneously for FB, Oracle, and Postgre, and I know 100% syntax only for Oracle. Currently I support an accounting product for 3 databases, interestingly AI knows about accounting, taxes, and our metadata more than I do. Naturally, all queries, whoever writes them, whether it is me or AI, must always be checked for the accuracy of the returned data.

1

u/BplusHuman Sep 29 '26

Google Translate fantastic... But actually knowing a language is INSANELY more efficient and accurate. That said, if my joins are really Byzantine I probably already wrote something that works and it's already portable enough to just repurpose. AI assistants are helpful for syntax I use EXTREMELY rarely or when I move between different DBMS and forget some nuance.

1

u/Better-Credit6701 Sep 09 '26

We won't allow AI to get near our data but since we all have RedGate installed, it pretty much gives you help finding the key you are joining on, completes what you are typing on especially once you add in your own short cuts.

I really don't use CTEs much since our databases are too large so it's temp tables where I can add an index. But to be honest, it's more of a habit since I'm sure our servers are beefy enough to handle it, a privilege after working on stressed out servers.

Even though I've been working with data for decades, I started by practicing on my own machine with data that I don't have to worry about. Optimizing, you can always use actual, estimates plans, live query stats, client stats to find the best plan

1

u/murdercat42069 Sep 09 '26

I always write the first draft and then enhance with AI. My first draft is almost always better because I know the subject matter and tables and it's much better than letting AI make the first pancake and doing a bunch of dodgy edits.

0

u/Infini-Bus Sep 09 '26

I write most of it myself still but sometimes I'm in a time crunch and I know exactly what I need but it'd be a relatively complicated script and will have an AI that I've been feeding schema and product info and examples of scripts with get me like 90% of the way there.  We can't just hand it access to the DB though.

 It does surprise me how well it does, but I do gotta read through it because it will make up columns or overengineer things sometimes.  So I go through and fix it up and make sure it's inline with my style.  It's been getting better at adhering to my style and not making stuff up as I iterate on it, tho.

I usually don't even use snippets, and I think that's to my benefit as I'll be able to recall what tables and joins need to be done off the top of my head.  When I'm helping newer colleagues and can just dictate/guide to them what SQL to write it gives me a confidence boost.

0

u/Spillz-2011 Sep 10 '26

Recently maybe 20%. I’m working on gh copilot skills to do most of the writing because other people are slow and bad.

-2

u/MrWillM Sep 09 '26

Depends on the query really. If it’s something simple or just an iteration Ill do it myself. If it’s a totally new query or bug fixes I use claude.

I do most of my best sql work building tools that integrate snowflake colab and g sheets though, and I claude all up and down that stuff.

-2

u/Uffda01 Sep 09 '26

I only dabble with a few queries here and there and I've never had formal training in anything coding/program related...but I only use AI to check my work or when I'm stumped. Basically the same thing I do when an excel formula doesn't work.