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
--刚才说差了 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.
select cast(9223372036854775807 as bigint)select cast(9223372036854775808 as bigint) --bigint 的上限是9223372036854775807
你可以写: select 16777216 * 222.0
或者写:select 16777216 * cast(222 as bigint)
select cast(9223372036854775807 as bigint)select 16777216 * 222.0
你这个是两个int类型的数据相乘 超出了int的范围好像在sql2000里int的最大值是2^30
在2005里int的最大值是2^31
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
--刚才说差了 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.
--bigint 的上限是9223372036854775807
这样:select 16777216.0*222
select 16777216 * 222.0