r/SQLServer • u/EchidnaFlowers • Apr 28 '26
Discussion “The script ran fine” and the data was still wrong
Had this happen after a migration.
Script ran clean. No errors. Everyone moved on.
A couple days later someone notices numbers don’t match, or a column suddenly has way more NULLs than it should.
Nothing “failed”. The script just did exactly what it was told.
Seen a few patterns:
- strings getting silently cut because the target column was smaller
- filters dropping more rows than expected
- mappings assuming data is always there when it isn’t
- constraints turned off “just for the migration” and never turned back on
None of that throws an error. You only see it when someone actually uses the data.
We started treating validation as a separate step. Row counts, quick spot checks, anything that shows “this doesn’t look right”.
Sometimes even just comparing source vs target catches things early (used dbForge Data Compare for that a couple times, mostly to avoid rewriting the same checks).
“no errors” just means it didn’t crash.
had cases where everything looked fine and then turned out wrong later?
2
u/Domojin Apr 28 '26
Just went through something similar at my workplace. Been here for almost 4 years and inherited a pretty bloated SSRS site. Just last month I had someone hit me up for one of the reports where the numbers weren't making sense to them and they were starting to see duplicates showing up. It was the first time someone was really looking at that particular report in... possibly ever. It's been running for years and years just throwing it's incorrect calculations at people this whole time. Whoever wrote the original procs are long gone, and I had to rewrite the whole thing. Sometimes it's impossible for a DBA to know these things without end user confirmation.
4
u/SQLBek 1 Apr 28 '26
"strings getting silently cut because the target column was smaller"
Yes, there's (at least) one scenario where a string can get truncated without an error thrown. And no, I don't remember the exact criteria - it was in a demo from a presentation that was part of my rotation about 10 years ago. It'll be buried in one of my demo scripts.
Regardless... moral of that story is to always explicitly right size your data types.
1
u/TravellingBeard 1 Apr 28 '26
Yeah, this is why you test in lower environments first. and insure the schema is identical in prod and lower ones first, before you implement new schema in your development.
Every time my company talks about CI/CD...I shudder. I've seen the code they deploy, and fixing it is making me so much money in on-call overtime. LOL (they're a bank so will be very slow, I know they need to fix it)
1
u/BigMikeInAustin Apr 28 '26
Yup. You can't see what's wrong if you don't put observeability on it.
1
u/[deleted] Apr 28 '26
[removed] — view removed comment