RT

解决方案 »

  1.   

    LZ 可以把SQL 贴出看看吗?
      

  2.   

             16777216*222  太大了``int没这么大
      

  3.   

    select  cast('16777216' as decimal)  *cast('221' as decimal)
      

  4.   

    16777216*222
    你这个是两个int类型的数据相乘 超出了int的范围好像在sql2000里int的最大值是2^30
    在2005里int的最大值是2^31
      

  5.   

    我知道了.加个cast(num as bigint)
      

  6.   


    select 16777216 * 222
    --Arithmetic overflow error converting expression to data type int.
    SELECT 1024*1024*1024
    select cast(16777216 as decimal)*cast(222 as decimal)
    --3724541952
    select cast(16777216 as float)*cast(222 as float)
    --3724541952
    select cast(16777216 AS float)* 222
    --3724541952
      

  7.   


    --刚才说差了 int在2005里的上限是2^31-1SELECT 1024*1024*1024-1+1024*1024*1024
    --2147483647
    SELECT 1024*1024*1024-1+1024*1024*1024+1
    --Arithmetic overflow error converting expression to data type int.
      

  8.   

    select cast(9223372036854775807 as bigint)select cast(9223372036854775808 as bigint)
    --bigint 的上限是9223372036854775807 
      

  9.   

    你可以写:    select 16777216 * 222.0
      

  10.   

    或者写:select 16777216 * cast(222 as bigint)
      

  11.   

    select cast(9223372036854775807 as bigint)select 16777216 * 222.0
      

  12.   

    你这是两个整数相乘。结果肯定是整数。但是整数最大值才是2147483647,你这结果超过了这个值,不溢出才怪
    这样:select 16777216.0*222
      

  13.   


    select 16777216 * 222.0