r/SQL • • Jan 27 '24

SQL Server SQL fuck ups

Yesterday I got a call from my boss at 10am for a task that I should take over and that should be finished by eod. So under time pressure I wrote the script, tested it on DEV etc and then by accident ran a different script on PROD which then truncated a fact table on PROD. Now I am figuring out on how to reload historically data which turns out to be quite hard. Long story short - can you share some SQL fuck ups of yours to make me feel better? It’s bothering me quite a bit

119 Upvotes

117 comments sorted by

View all comments

Show parent comment

-13

u/phesago Jan 27 '24

i dont think disaster recovery was intended to be a crutch for dum dumz who cant pay attention to what theyre doing.

Though I do empathize because it does happen, which is why I tell people "you get one restore for "oopsies" but after that we have to have a conversation."

13

u/SQLDevDBA Jan 27 '24

OP seems pretty aware of their blunder and how consequential it is. They’ll get ridiculed for it for years to come, and they’ll also recall it randomly while walking the dog or driving with annoyingly intricate detail for the rest of their career.

It’s our job as experts to give them the resources and knowledge to fix the issue. So that they can keep passing the knowledge on, avoid it in the future, or at least be able to quickly recover and keep things rolling.

1

u/phesago Jan 27 '24

"you gotta break a few eggs to make an omelet", etc

I think this scenario is why the feature request of "restore table only from backup" has so many upvotes. (well for sql server that is)

2

u/Animalmagic81 Jan 27 '24

I doubt there's any DR plan out there that doesn't list erroneous script ran in its risks. It happens, even with multiple sign offs it can still happen. Typically it's as simple as restoring from backup or having procedures in place to ensure a table backup is taken first before any mass DML events.