SQL Server : Arithmetic overflow error converting expression to data type int

前端 未结 6 1477
说谎
说谎 2020-12-29 18:17

I\'m getting this error

msg 8115, level 16, state 2, line 18
Arithmetic overflow error converting expression to data type int.

6条回答
  •  醉话见心
    2020-12-29 18:40

    Change SUM(billableDuration) AS NumSecondsDelivered to

    sum(cast(billableDuration as bigint)) or

    sum(cast(billableDuration as numeric(12, 0))) according to your need.

    The resultant type of of Sum expression is the same as the data type used. It throws error at time of overflow. So casting the column to larger capacity data type and then using Sum operation works fine.

提交回复
热议问题