r/SQL • u/metric_skeptic • Sep 28 '26
Discussion How are you automating your SQL work?
Curious what people are actually using to automate or speed up their SQL work.
Python scripts? dbt? AI? Stored procedures? Some IDE/tool I’ve never heard of?
I feel like there are probably a bunch of useful tools and workflows I’m not aware of.
What are you using that actually saves you time?
60
Upvotes
72
u/EbbyRed Sep 28 '26
I don't need to automate my SQL work. 50% of the job is knowing the source data structure and purpose, 40% is creating real business requirements from the ones stakeholders attempt to put together,and 10% is actually writing any SQL.
16
u/gumnos Sep 28 '26 edited Oct 01 '26
the biggest time-saver for me came from creating a web-interface for dynamic reports. Many moons ago, I'd get regular requests for reports, but writing the SQL itself usually took 5–15min while wrapping it in some Crystal Reports wrapper, creating variables, adjusting headers, fonts, etc, and making it less-than-ugly took easily 2–3× the time, and they were kinda fragile.
Instead we implemented a dynamic-reporting engine in the in-house web-portal. It let me dump SQL queries in a text-box, give them a searchable name/description, quickly add a few common parameters (including pick-lists from other query-output) and formatting aspects, as well as some basic visibility-permissions. With this in place, I could usually turn around new-report requests in those 5–15min rather than 1–2hr wasted pushing around fields in Crystal Reports.
And users could search for previously-existing reports which saved me from having to remember if the request for This Report was the same as That Report that I created a couple months ago. So it saved me from a lot of new-report requests.
Over time, it also grew some additional functionality like
7
u/Eastern_Habit_5503 Sep 28 '26
Automate? I need job security! Unless my boss is making me automate things, I’m sticking with manually running my custom T-SQL code snippets and some stored procedures that have no set day or time to run via SQL Job Agent.
3
u/karakanb Sep 28 '26
You should check-out Bruin: https://github.com/bruin-data/bruin
It's open source, lets you orchestrate SQL + Python in the same workflow, ingests data from 150+ sources, has VS Code and Cursor extensions, and runs fast anywhere. I am one of the founders, would love to hear the feedback on it.
3
u/Prestigious_Bench_96 Sep 28 '26
Spend a lot of time on modeling tables/deterministic checks (grain, values, etc); then let LLMs model against that and to deterministic query generation. Any semantic modeling solution that you can bear to work with is good for this; I have my own since I hate YAML.
Then any repeated operations you can move up into the semantic layer as reusable definitions you can test; your actual written SQL then stays small and easy to understand. As others note the writing SQL is both a relatively small part of the total workflow and the bit that's easiest to automate away, so this is mostly about freeing up time to actually *think* about the data and be able to delegate more exploration to agents because there's a class of errors they'll avoid. (this thing looks weird, go investigate; profile the trends in this data over time, etc).
This lets me spend most of the time thinking about the domain itself; what is the right way to model data and how does the production data (inevitably) fail to match my expectations in weird ways.
4
u/iLeKtraN Sep 28 '26
Where I am the servers and instances are all on-prem. The automation is entirely scheduled agents executing stored procedures. Most of them were originally hand written DML, but now I am leveraging AI to assist in expending some of the more complex processes and generating reconciliation and verification scripts.
2
u/GreatMyUsernamesFree Sep 29 '26
Mostly queries about queries. I can't check each one individually so I write a lot of performance analysis queries for field utilization, indexes, reports, stored procedures and SQL agent jobs. 90% of the results are for my eyes only--i'm the only one doing db performance analytics so they go through SSIS or agent jobs. Of the remaining 10% it's probably split evenly between powershell when routine actions need to be performed on another server in response to the result set or power automate when a user has to take action based on the results.
2
u/Pawelm_rot Sep 29 '26
In my day‑to‑day work the most monotonous part wasn’t writing SQL, it was propagating dozens or sometimes hundreds of scripts across many databases and servers.
Sometimes developers would hand me a whole pack of scripts and ask me to run them everywhere in a specific order.
I eventually built a small tool that can execute many scripts across many servers and databases at once, with parallel execution. I showed it to the developers. Now this whole task is off my plate.
It didn’t automate SQL itself, just the boring operational part around it, but it saved me a huge amount of time.
1
u/navicat-gu Oct 21 '26
In practice, most of the time I save comes from a few unglamorous things:
pg_cron, the MySQL event scheduler, or plain cron or Task Scheduler callingpsql/sqlcmd. Email or drop the output somewhere people can find it.ref(), tests (unique,not_null,relationships) and docs remove a lot of manual checking.ROW_NUMBER(), gaps-and-islands, "find duplicates by key", standard audit columns. This is honestly the biggest daily time saver.Disclosure: I'm RC, Director of Digital Strategy @ Navicat. If you'd rather click than script, Navicat 18's Automation (paid Premium editions) can schedule queries, backups, data transfers and exports, and email the results. Navicat Premium Lite is free to try and includes code snippets and query history for the day-to-day part.
1
u/fraser_altimate Oct 23 '26
for dbt work, staying in the editor saves me the most time: compiled sql preview, lineage, running one cte without copy paste. dbt power user does those in vs code / cursor (i work on it). outside dbt, sqlfluff in pre-commit saves a ton of review time
1
u/DarlanSandro Oct 01 '26
O que mais acelerou meu trabalho foi combinar dbt, DuckDB e IA na IDE.
O dbt cuida das dependências, testes e transformações reutilizáveis. O DuckDB é ótimo para consultar CSV e Parquet localmente sem criar tabelas temporárias. Já a IA ajuda com o código repetitivo, como listas de colunas,
CASE WHENe funções de data.Também uso SQLFluff para padronização. A IA escreve o rascunho, mas joins, cardinalidade e regras de negócio ainda precisam de validação humana.
1
u/Glitch_In_The_Data Oct 10 '26
I got mass productivity gains once I started using AI directly inside my sql workflow instead of bouncing between tools. We are now moving to Databricks platform and Genie lets users ask data questions in plain English… and it writes the sql for the users against actual tables. For heavier stuff like building pipelines or transformations, dbt is still great… but for fast exploratory work and adhoc analysis, having an AI that already knows the schema and tables is better.
1
u/alertetainry Oct 12 '26
DbForge Edge helps cut down manual schema diffs and query writing when you want to auto the tedious stuff across mixed engines
1
u/GangreneTVP Oct 20 '26
If you're talking about writing the SQL. I do all of that myself. On a very rare occasion I might ask Gemini how it would it would do something and compare it's execution plan to my own and maybe discuss it with the AI. That's like 1% of the time.
If you're asking how I automate functionality. I'm working in Microsoft SQL server environments and I use SQL server jobs with SSRS packages. For data transfers I'm using Putty, WinSCP, and commands to execute those SFTP transfers inside the Jobs. I do a lot of data integrations... Creating and transforming datasets into files compatible with other systems and sending that data to the other system.
1
u/alertetainry Oct 26 '26
One area worth automating is schema comparison, especially when you're dealing with multiple environments. dbForge has Schema Compare tools that can help with detecting differences and generating synchronization scripts. Still worth reviewing the scripts before applying changes to production.
1
u/heeero__ Sep 28 '26
SQL Server Jobs are very underrated. We use them for everything. SQL maintenance, reports, SSIS packages, etc.
1
u/ChaosEngine-6502 Sep 28 '26
If it's something that needs to be executed repeatedly, I typically build a script or a stored procedure and have it called by SQL Server Agent.
With that said, working in healthcare integration, we do a ton of stuff that automates database CRUD transactions via our middleware integration engine. The whole reason our team exists is to automate.
1
u/ThisIsFun- Sep 29 '26
lots of questions come my way from the business so genie and genie code have been amazing. this way anyone who asks questions uses their own language to get answers instead of me being in the middle. it took some time to get comfortable with this and we did lots of testing but I cannot imagine without it now
0
u/Ifuqaround Sep 30 '26 edited Sep 30 '26
I don't.
I mean if you want to give them reasons to replace you, go ahead lol.
Lots of analysts are not going to have jobs soon. Well, even more so.
I'm in healthcare. I'm a 'mentor' on vendor forums and we would get hammered with report/oracle sql/snowflake requests daily.
LLM's came and guess what? Just like stack overflow and shit...the requests slowed down big time because everyone is using LLM's to write their queries. The shitty part is everyone is feeding their company data to the LLM's as well without worrying about consequences.
You think a junior analyst gives a shit if he dumps his company's data into an LLM to create a query that will possibly make him look like some fucking guru? Not a chance...that junior is going to be pumping the LLM's full of info to make sure he keeps his job and his paycheck.
-edit- added words
Most of these people in these analysts positions have no skill and are faking it until they make it now. I'm kind of embarrassed to be in this profession. My skill had 'weight' at one point, but now programmers are a dime a dozen.
0
u/samwise970 Sep 28 '26 edited 10d ago
The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.
Knee bike work knee boast pocket cows peach
0
u/alexpj11235 Sep 28 '26
Stored procedures, ran through agents / jobs, orchestrated by AWS step functions.
0
u/BarfingOnMyFace Sep 28 '26
I do initial DDL by hand, set a precedent, then have AI use it. Then I follow suit with my DML code. If I find conventions for the triggers, views, functions, procedures i am writing, i will have the AI build auto-gen code to successfully follow those conventions, then have AI rely on the auto gen process for build out of other objects as it tends to be a lot cheaper.
Some of these AI IDEs are making context much more cohesive across your entire model, so the people making that recommendation to use such tools are spot on.
0
u/DaOgDuneamouse Sep 28 '26
I usually don't automate stuff. Most of my job is building code for reports or ETL jobs. I do have one static table though that needed about 2,000 rows added to it. I built the table in excel and used excel formulas to build the SQL to insert the data into the table. One cut and paste later and all 2,000 rows were added with perfect documentation.
0
u/gumnos Sep 28 '26
in addition to my other response here, I'll also include that certain repetitive tasks can be automated by writing meta-SQL…queries that create queries, usually using system tables like
INFORMATION_SCHEMA.*. It's particularly useful when spelunking in a new database-schema where you're not quite sure what various tables/columns contain. It might not be particularly efficient at runtime, but most exploration only happens as a one-off. Hopefully you learn what you need based on those potentially-inefficient queries, and can then write better/faster/more-accurate production queries because of what you learned.0
u/ihaxr Sep 28 '26
Mostly admin work, so dbatools and stored procs for frequently run data fixes.
Deployments and whatnot all go thru octopus deploy
0
u/rabel10 Sep 28 '26
I create alot of views these days, usually working in Lakeflow. That view can be queried or pulled into a dashboard or whatever. I'll offload the heavy lifting to Lakeflow and make smaller queries on that view if I need to do anything. Helps create lineage of metrics and work, and larger queries and workloads can go into a materialized view so that dashboards aren't stuck on refreshing forever.
dbt accomplishes almost the same task, just with a bit more manual setup. CI/CD is a bit more difficult in dbt I find.
0
u/SomeoneInQld Sep 28 '26
having juniors who can do the 'bulk' of the bullshit level work
0
u/ArielCoding Sep 29 '26
Track where your time goes for a week, most people find it’s redoing the same request and reexplaining data. Report libraries, semantic layer and tested views save time by turning one off answer into reusable stuff.
0
u/Winterfrost15 Sep 29 '26
SQL Agent Jobs calling SSIS Packages. Stored Procedures, and Powershell scripts. It works great for most needs.
0
u/RandomiseUsr0 Sep 29 '26
Using a spreadsheet is an underestimated cheap data import solution - for when you need it, remember it’s there - turn your data into DML and you’re good to go
-1
u/smolhouse Sep 28 '26
An existing code base to reference and using LLMs for architecture design saves me the most time.
I still like to roll up my sleeves and actually write the code myself instead of just feeding everything into an LLM with detailed prompts and copy/pasting it back. Probably slower, but it helps keep me sharp and I have a better understanding of what's happening.
0
u/[deleted] Sep 29 '26
[deleted] — view deleted comment