-- Validate conversion coverage before cutover
SELECT
    COUNT_BIG(*) AS total_rows,
    SUM(CASE WHEN customer_id IS NOT NULL AND TRY_CONVERT(BIGINT, customer_id) IS NULL
        THEN 1 ELSE 0 END) AS conversion_failures
FROM stg_orders;

-- Validate downstream null and key behavior after migration
SELECT customer_id, COUNT_BIG(*) AS row_count
FROM stg_orders
GROUP BY customer_id
HAVING customer_id IS NULL;
