'How can I know which value raise the error `Arithmetic overflow error converting numeric to data type numeric.`

I'm doing an ETL processes with some SQL Server procedures.

WITH CTE (qty_top, qty_lvl) AS 
(
    SELECT
        CONVERT(decimal(20,6), t.unity),
        CONVERT(decimal(20,6), t.unity)
    FROM
        top_tab 
     
    UNION ALL

    SELECT
        CONVERT(decimal(20,6), cte.qty * t.unity),
        CONVERT(decimal(20,6), nom.Nomenclature_unite_production)
    FROM
        CTE_NOM cte
    JOIN
        tab t
)
     

This is my SQL Request (very simplified). When I do this, this raise me an Arithmetic overflow error converting numeric to data type numeric.

I tried to change my decimal(20,6) into a bigger number (30,6) but it still doesn't work.

How can I know which values raise me this error ? So It can help me to resolve this error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source