如题,我现在用的float类型,但只要是存入1.0 2.0 3.0  ....这类的数据,它自动就变成1 2 3 了,要咱个办呢?

解决方案 »

  1.   

    decimal(2,1)  这样?要不你用 字符类型好了
      

  2.   


    declare @table table (col numeric(16,1))
    insert into @table
    select 1.0 union all
    select 2.0 union all
    select 3.0select * from @table
    /*
    col
    ---------------------------------------
    1.0
    2.0
    3.0
    */
      

  3.   

    decimal和numeric是一样的,把小数位数设定一下就好了
      

  4.   

    浮点类型 一般 就 double float  decimal(numeric)
    double 的长度最大 精度最高  例如 1.01023231 的数字 存入到数据库里就也是1.01023231
    float 的长度没有double大 ,但一般也够用了 存取数据与double一致
    decimal 可以限制小数点的长度 ,他的取值范围肯定没有double 与 float的 范围大 但一般也够了
    decimal(2,1) 就代表 2位数 小数点后 保留1位