sql server – Possible to detect when arithmetic overflow would occur before POWER(x,y) is executed?
Example:
-- inputs
declare @x decimal(28,10) = 10001.0
declare @y decimal(18,6) = 7.0
-- later on, inside a udf
select POWER(@x, @y)
Result:
Msg 8115, Level 16, State 6, Line 13
Arithmetic overflow error converting float to data type numeric.
I understand why the overflow is occurring. My question is, is it possible to detect,
just before POWER is executed, whether the overflow would occur? Note that the code is run inside a UDF, so cannot use TRY…CATCH. If I can detect it in advance, I can take avoiding action (e.g. return NULL for the result, which is suitable for my requirements).
Read more here: Source link