r/SQL • u/metric_skeptic • 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
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.
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.
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.
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.
129
u/Jon-Robb Sep 09 '26 •
I don't even write my -- reddit posts
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.
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.
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
4
u/Gm24513 Sep 09 '26
If you do sql with AI you're just begging to get fired or worse.
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.
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.
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/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.
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/SubjectCode1940 Sep 09 '26
99 percent.
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/shitfuckvaginacunt Sep 10 '26
0.1%
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/wellseasonedwell Sep 10 '26
0%
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/North_Transition3542 Sep 10 '26
100% AI
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.
0
u/[deleted] Sep 09 '26
[deleted] — view deleted comment