日期:2014-05-18  浏览次数:20629 次

在SQL Server的新建查询中运行下面的语句,得到的结果是()
create table numbers
(
n1 int,
n2 numberic(5,0),
n3 numberic(4,2)
)
go


insert numbers values(1.5,1.5,1.5)
select *
from numbers
go

答案是1、2和1.50的结果集,我想问的是那个2怎么来的?

------解决方案--------------------
四舍五入
SQL code
select cast(1.4 as numeric(5,0)) as num1,cast(1.5 as numeric(5,0)) as num2
/**
num1                                    num2
--------------------------------------- ---------------------------------------
1                                       2

(1 行受影响)
**/