CASE STUDY · MANUFACTURING AND DISTRIBUTION · LEGACY ANALYSIS

Reading 47 SQL Queries to Find the Rules Behind the Numbers

Before we could compare a single number, we needed to know what the old reporting actually calculated. The only complete record was the code, so we read it.

The Challenge

The legacy process was two SSIS packages. The first copied about 75 tables from the Dynamics AX 2009 ERP into a staging database, truncating and reloading them on every run. The second ran 47 SQL queries against that copy and wrote about 45 tables for the reporting layer.

There were no transformations inside SSIS itself. All of the business logic lived inside those queries: what counts as on-hand stock, how cost is picked, what counts as usage. That made the code the only complete record of what the reports meant.

What We Did

We went through both packages task by task and built a logic register: a workbook with one row per business rule. Each row records the definition as found in the SQL, the output tables that use it, what looked unclear or wrong, and where the rule should live in Fabric, whether a Power Query step, a column on a dimension, or a DAX measure.

The same workbook inventories all 135 data flows and SQL tasks in the two packages, maps every source table to what it feeds, and keeps the full SQL text unedited beside each row. It ended with 23 rules and 13 open questions for the company's IT team and the person who owns the numbers.

What We Found

A few of the findings, written the way we handed them over:

  • On-hand quantity had two definitions in different places in the code.
  • Standard cost ignored the price unit field.
  • Usage was bucketed by calendar year, which may not match the company's fiscal year.
  • Items that sat in two forecast models were counted twice.
  • Weekly usage was calculated two different ways depending on the report.
  • One list of excluded planner codes held a code with a leading space, which can silently fail to match.

We did not decide which version was right. Each one went on the open questions list for the person who owns the numbers, because the answer depends on what the business meant, not on what the code does.

The Outcome

The company has a written record of how its inventory numbers are built, with every rule tied to the query it came from. Every measure we built in Fabric traces back to a row in the register.

That changes the first question when a number looks off. Instead of asking which system is right, you ask which rule differs, and you can look it up.

23

Business Rules Documented

47

SQL Queries Read

135

Flows and Tasks Inventoried

13

Open Questions Logged for the Business

Have a Similar Project?

Free 30-minute call. We'll tell you how we'd approach it and what it would cost. No pitch, no pressure.