我的存储过程是这样的:
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)请大侠指点,谢谢。
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)请大侠指点,谢谢。
具体地说就是如果是decimal的话,看你精确到小数点多少位,默认是0。
所以会四舍五入,6.5——>7
(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
1.
我数据表定义的字段medicalfee和others,都是demical型18位精度,2位小数
2.
我用update ...set的结果也对
但是存储过程执行的不对
select 2.0/3--结果为.666666
楼主明白没,在你传参时的数字类型决定了结果.
declare @i decimal(15,2),@j numeric(15)
select @i=6.5
select @j=@i
select @j
-----------------
7(所影响的行数为 1 行)