How to sum bigints in sql-server, while ignoring arithmetic overflow error?

Viewed 69

I am running select sum(x) from y, where x is of type bigint, and contains 64-bit numbers.

Sql-server throws Arithmetic overflow error converting expression to data type bigint.

I am fine with just ignoring the overflow, the way C would. I only need the lower 64-bits of the result.

If I was trying to sum ints, I could convert them to bigint and then the sum would complete in every practical query. But what do I do when I want to sum bigints?

0 Answers
Related