First off, we are on Azure SQL DB (now that's said).
We have a calculations table that stores math strings. I'm attempting to get answers from math strings by running them through Exec command.
Simple example EXEC ('select ' + '500*5000') works fine.
EXEC ('select ' + '7500000*10000000000') also works fine.
However
EXEC ('select ' + '75000*1000000') produces Arithmetic overflow error
Huh?
Doesn't the second example also result in a bigint? Why is that one ok?
From what I can tell, there is a background process to dynamically determine the size of the resulting data type. In any case, we need to make sure no calculations error out due to overflow.
My question is how can I force bigint on any evaluation?
I've tried
EXEC ('select cast(' + '750000*1000000' + 'as bigint)')
and
EXEC ('select convert(bigint,' + '750000*1000000' + ')')
Alternatively, is there a setting we can tweak to tell the server to use bigint by default in evaluations?