I am using python's pypyodbc to process some sql BULK insertion cmds on a SQL Sever Database. Yet, at the logs I found:
python load_d 4c24-4ea4 ENTER SQLExecDirect
HSTMT 0x000000000336C260
UCHAR * 0x0000000003A91188 [ 67] "\ a SELECT COUNT(*) \ a FROM out_table\ a "
SDWORD 67
python load_d 4c24-4ea4 EXIT SQLExecDirect with return code -1 (SQL_ERROR)
HSTMT 0x000000000336C260
UCHAR * 0x0000000003A91188 [ 67] "\ a SELECT COUNT(*) \ a
FROM out_table\ a "
SDWORD 67
DIAG [22003] [Microsoft][SQL Server Native Client 11.0][SQL Server]Arithmetic overflow error converting expression to data type int. (8115)
Could the COUNT(*) be returning a very big value that "escapes" from the INT limits?
Yes. It can. To deal with this issue Microsoft introduced COUNT_BIG-function Please see details here https://learn.microsoft.com/en-us/sql/t-sql/functions/count-big-transact-sql?view=sql-server-ver15