看下
create table numbers
(
n1 int,
n2 numeric(5,0),
n3 numeric(4,2)
)
go
insert numbers values (1.5,1.5,1.5)
select * from numbers结果是
n1          n2      n3     
----------- ------- ------ 
1           2       1.50n2怎么理解,难道是四舍五入?

解决方案 »

  1.   

    n1 int
    1.5取整为1(同理1.9取整也为1)n2 numeric(5,0)
    1.5四舍五入为2,因为你定义的是没有小数位.n3 numeric(4,2) 
    定义两位小数位,1.5不足位用0补足.
      

  2.   

    不是已经告诉你了.你定义的是:numeric(5,0),没有小数(位).
      

  3.   


    decimal 和 numeric
    带定点精度和小数位数的 numeric 数据类型。decimal[(p[, s])] 和 numeric[(p[, s])]定点精度和小数位数。使用最大精度时,有效值从 - 10^38 +1 到 10^38 - 1。decimal 的 SQL-92 同义词是 dec 和 dec(p, s)。p(精度)指定小数点左边和右边可以存储的十进制数字的最大个数。精度必须是从 1 到最大精度之间的值。最大精度为 38。s(小数位数)指定小数点右边可以存储的十进制数字的最大个数。小数位数必须是从 0 到 p 之间的值。默认小数位数是 0,因而 0 <= s <= p。最大存储大小基于精度而变化。
      

  4.   

    ding