Can SQL Server’s SUM aggregate on `int` and `bigint` explicitly allow overflow?

Is there any way to force the SUM aggregates on int and bigint to explicitly allow overflow?

That is, is there any way to get the queries below to return -2147483648 and -9223372036854775808 respectively, instead of giving an “Arithmetic overflow” error?

select SUM(x) as sumx
from (
    select 2147483647 as x
    union select 1 as x) a;


select SUM(x) as sumx
from (
    select cast(9223372036854775807 as bigint) as x
    union select 1 as x) a;

I tried to SET ARITHABORT OFF; and SET ANSI_WARNINGS OFF;, but that just gives me NULL instead of a number result, so that doesn’t seem to help.

Read more here: Source link