1. Problem description
SQL Server (SQL DW) queries the number of data in a table and reports an error using count
select count(*) from test.test_t;
Then an error is reported:
SQL ERROR [8115] [S0002]: Arithmetic overflow error converting expression to data type int.
2. Cause of the problem
The amount of data is relatively large. The query result directly with count is of type int, which exceeds the range of int.
tinyint: integer from 0 to 255
smallint: integer from – 2 15 (-32768) to 2 15 (32767)
int: integer from – 2 31 (-2147483648) to 2 31 (2147483647)
bigint: integer data (all numbers) from -2 63 (-9223372036854775808) to 2 63 -1 (9223372036854775807) decimal: numeric data with fixed precision and range
from -10 38 -1 to 10 38 -1
3. Solution
Microsoft sql provides count_big method to count
select count_big(*) from test.test_t;
Read More:
- [Solved] runtime error: reference binding to null pointer of type ‘std::vector<int, std::allocator<int>>‘
- How to Solve Error Swift 4 Expression type ‘@value CGRect’ is ambiguous without more context
- TensorFlow issue: Expected int32, got list containing Tensors of type ‘_Message’ instead.
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- How to Fix Microsoft SQL Server Error 1326
- [Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>
- [Solved] pagehelper Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LIMIT 1’
- [Solved] MindSpore Error: Select GPU kernel op * fail! Incompatible data type
- [Solved] MindSpore Error: Data type conversion of ‘Parameter’ is not supporte
- [Solved] error converting to execution character set illegal byte sequence
- [Solved] MindSpore Error: StridedSlice operator does not support input of uint8 data type on Ascend hardware
- [Solved] The method getContextPath() from the type HttpServletRequest refers to the missing type String
- [Solved] ROS Error: cannot launch node of type [octomap_server/octomap_server_node]:octomap_server
- [Solved] Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“
- [Solved] Failed to load response data: no data found for resource with given identifier
- [Solved] Git error: inflate: data stream error (invalid block type) error: corrupt loose object
- Libtorch Error: Expected object of type Variable but found type CUDALongType for argument #2 ‘index’
- keil: ERROR L107:ADDRESS SPACE OVERFlOW [How to Solve]
- How to Solve Keil Error: error: #29: expected an expression