Answer the question
In order to leave comments, you need to log in
SQL SERVER arithmetic overflow error. Why such behaviour?
Maybe a pretty simple question.
But I would like to know how it works.
Why
SELECT 2000000000 * 3
--Ошибка арифметического переполнения при преобразовании expression к типу данных int.
SELECT 3000000000 * 3
-- 9000000000
create view ts
as
SELECT 2000000000 * 3 AS A, 3000000000 * 3 AS B
Answer the question
In order to leave comments, you need to log in
This happens because 2000000000 still fits in an int, but 3000000000 doesn't.
https://docs.microsoft.com/en-us/sql/t-sql/data-ty...
int -2^31 (-2 147 483 648) to 2^31-1 (2 147 483 647 )
If you need nothing to collapse, you can do this:
SELECT 2000000000.0 * 3 AS A, 3000000000.0 * 3 AS B
With this option, there will already be a float
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question