■ Project #04 — Legacy Modernisation
⬡ Client Engagement
Refactoring a 5,000+ Line
Legacy SQL Stored Procedure
A single monolithic SQL Server stored procedure exceeding 5,000 lines handled everything —
extraction, transformation, business logic, and report aggregation. Execution took 45–60 minutes
and any change risked breaking downstream reports. The procedure was decomposed into a modular
SSIS ETL architecture backed by a dimensional data warehouse, cutting run times to 10–15 minutes
and dramatically improving maintainability.
Operational DBs
→
SSIS Extraction
→
Staging Tables
→
Transform Layer
→
Star Schema DWH
→
BI Reports
This is the core fact table load that replaced the 5,000-line monolith — aggregating sales revenue and order counts by date, product, and region into a clean, modular step that all downstream BI reports now depend on.
-- Before: monolithic CASE logic buried in 5,000+ line proc
-- After: isolated, testable transformation step
INSERT INTO fact_sales_summary (date_key, product_key, region_key, total_revenue, order_count)
SELECT
dk.date_key,
pk.product_key,
rk.region_key,
SUM(s.amount) AS total_revenue,
COUNT(s.order_id) AS order_count
FROM staging_sales s
JOIN dim_date dk ON CAST(s.order_date AS DATE) = dk.full_date
JOIN dim_product pk ON s.product_id = pk.source_product_id
JOIN dim_region rk ON s.region_code = rk.region_code
GROUP BY dk.date_key, pk.product_key, rk.region_key;
SQL Server
T-SQL
SSIS
Star Schema
Data Warehouse
ETL Pipelines
Legacy Refactoring