The Solution 1 given by Mehdi Gholam
is very good.
I want to add the following since the OP wants to know specifically why error was not thrown in the first case and why error is thrown in the second case.
As seen from the statements
SELECT CAST(1234567891234567.34 AS NUMERIC(18,2)) SELECT CAST(1234567891234567.34 AS NUMERIC(18,10))
it is clear that, in the first case from the statement
the total digits are 18 and 16 digits are available to the left of decimal, whereas
are 16 digits. Hence, there is no error.
In the second case, from the statement
, 8 digits are available to the left of decimal, but
are 16 digits which is more than 8 digits. Hence, Arithmetic overflow error occurs.