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:
- Excel VBA on error resume next error handling
- [Solved] ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
- Impala Find Error: TFetchResultsResp(status=TStatus(errorCode=None, errorMessage=‘UDF ERROR: Decimal express
- [Solved] Excel solver: Error Log 3_Decimal result after non negative constraint
- Error: (list) object cannot be coerced to type ‘double’
- Filezilla Error: You appear to be behind a NAT router. Please configure the passive mode settings and …
- How to Solve Error Swift 4 Expression type ‘@value CGRect’ is ambiguous without more context
- [Solved] keil2 Error: FATAL ERROR L210: I/O ERROR ON INPUT FILE
- React Hook “useState“ is called in function “xxx“ which is neither a React function component or
- (How to Fix) Ora-00600: internal error code, arguments: [4194]
- Jmeter Error java.net.BindException: Address already in use: connect
- [USF-XSim-62] ‘elaborate‘ step failed with errors.[Vivado 12-4473] Detected error while running sim
- [Solved] VINS-MONO: integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
- [Solved] Excel plug in installation failed: unable to resolve the value of property ‘type’
- [Solved] std::max() error C2589: ‘(‘ : illegal token on right side of ‘::‘
- SSH integration error: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[……]
- runtime error ‘9’: subscript out of range error in VBA programming
- Error: stat_bin() must not be used with a y aesthetic.
- C++ Opencv+BaiDu OCR“error“: “unsupported_grant_type“, “error_description“: “The authorization grant