Query IS Correct

I worked for a company once where I was to implement some process' for the Month End.

So I reviewed the existing code.

Basically, it was written in Visual Basic 6.

There was an outer query, which looped thousands of times.

Each time it called an inner query.

I reviewed the code.

And found a bug.

So I brought it to my boss' attention.

He said "that is impossible, the entire company bases it's financial life on that query.  The query IS correct".

I said "okay boss".

And that was that.

A few days later he called me into his office.

"So tell me again what is wrong with the query."

I showed him.

Sure enough it was wrong.

So he told me to fix it.

And then I reviewed the code for performance.

I removed the logic from Visual Basic Inner / Outer queries and put the code into SQL-Server stored procedure.

It reduced the run time from 5 hours to 10 minutes.

And then I was the month end specialist for the next 3 years.