--try as decimal(19,3)与字段c一样 
update Orders set 字段C= cast(1-(字段A % 字段B) as decimal(19,3)) where ID=7 

解决方案 »

  1.   

    update Orders set 字段C= 1-cast((字段A % 字段B) as numeric(12,2) where ID=7 
      

  2.   

    字段c定义有问题,应该有整数部分,如decimal(10,5),而不应该没有整数部分如decimal(10,10)
      

  3.   

    -->这样看行不行
    update Orders set 字段C= 1-(字段A*1.0 % 字段B*1.0) where ID=7 
      

  4.   

    alter table alter column C decimal (18,3)
      

  5.   


    alter table Orders alter column C decimal (18,3)
    update Orders set 字段C= 1-(字段A*1.0 % 字段B*1.0) where ID=7 
      

  6.   

    还是没有解决:比如
    update Orders set 字段C= cast(1-(40 % 100) as decimal(5,3)) where ID=7
    得出来的结果是-39
      

  7.   

    5,3太小了,如果101%102=101,1-101==100,就超出了,你要么干脆用int(你的算法不会有小数部分),或者就用
    DECIMAL(N,1),N大些,比如DECIMAL(18,1)
      

  8.   

    问题是再怎么设,上面的结果不对啊,
    update Orders set 字段C= cast(1-(40 % 100) as decimal(18,3)) where ID=7 
    我要的答案应该是0.6 或者0.6000
    而不是-39
      

  9.   

    晕,你不知道%是取模运算就敢用?如果你要0.6,应该这么写update
    update Orders set 字段C= 1-(1.0*字段A / 字段B) where ID=7 
      

  10.   

    update Orders set 字段C= cast(1-40*1.0/100 as decimal(18,3)) where ID=7
      

  11.   

    update Orders set 字段C= cast(1-(字段A / 字段B) as decimal(19,3)) where ID=7