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

前端 未结 6 1439
说谎
说谎 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:38

    SELECT                          
        DATEPART(YEAR, dateTimeStamp) AS [Year]                         
        , DATEPART(MONTH, dateTimeStamp) AS [Month]                         
        , COUNT(*) AS NumStreams                        
        , [platform] AS [Platform]                      
        , deliverableName AS [Deliverable Name]                     
        , SUM(billableDuration) AS NumSecondsDelivered
    

    Assuming that your quoted text is the exact text, one of these columns can't do the mathematical calculations that you want. Double click on the error and it will highlight the line that's causing the problems (if it's different than what's posted, it may not be up there); I tested your code with the variables and there was no problem, meaning that one of these columns (which we don't know more specific information about) is creating this error.

    One of your expressions needs to be casted/converted to an int in order for this to go through, which is the meaning of Arithmetic overflow error converting expression to data type int.

提交回复
热议问题