我的存储过程是这样的:
ALTER PROCEDURE pr_updateBill
(@billid int,@days decimal,@medicalfee decimal(18,2),@others decimal,@comment nvarchar(200))
AS
update dt_bill set days=@days,medicalfee=@medicalfee,others=@others,comment=@comment where billid=@billid
RETURN 现在出现奇怪的现象
当我用
@medicalfee
@others
用值6.5修改时
数据库中存储的是
7.00
字段medicalfee
在数据库中存储格式是decimal(18,2)请大侠指点,谢谢。

解决方案 »

  1.   

    用medicalfee=@medicalfee*1.0 试试
      

  2.   

    decimal(p,s)p(精度)指定小数点左边和右边可以存储的十进制数字的最大个数。精度必须是从 1 到最大精度之间的值。最大精度为 38。s(小数位数)指定小数点右边可以存储的十进制数字的最大个数。小数位数必须是从 0 到 p 之间的值。默认小数位数是 0取决于你数据表定义的字段medicalfee和others,是什么类型,
    具体地说就是如果是decimal的话,看你精确到小数点多少位,默认是0。
    所以会四舍五入,6.5——>7
      

  3.   

    试验了一下,没有问题啊create table temp 
    (num1 decimal(18,2),num2 decimal)insert into temp
    select 7,7
    update temp set num1=6.5,num2=6.5
    select * from temp
    -----------
    num1   num2
    6.50 7
      

  4.   

    To:rookie_one
    1.
    我数据表定义的字段medicalfee和others,都是demical型18位精度,2位小数
    2.
    我用update ...set的结果也对
    但是存储过程执行的不对
      

  5.   

    select 2/3--结果为0
    select 2.0/3--结果为.666666
    楼主明白没,在你传参时的数字类型决定了结果.
      

  6.   

    如下列子:
    declare @i decimal(15,2),@j numeric(15)
    select @i=6.5
    select @j=@i
    select @j
                      
    ----------------- 
    7(所影响的行数为 1 行)