sql server 2000中的小数点四舍五入的问题
表一productid  price
1   303.5    
2   413.2现在想用update把price的值变成304、413(把小数点四舍五入)
,有时在2005下可以,但在2000下就不行了,还望高手解答一下,谢谢。。

解决方案 »

  1.   

    select cast(round(303.5,0) as int),round(413.2,0)
    304 413.0
      

  2.   

    --> 测试数据: @T
    declare @T table (id int,price numeric(4,1))
    insert into @T
    select 1,303.5 union all
    select 2,413.2select id,round(price,0) price
    from @T/*
    id          price
    ----------- ---------------------------------------
    1           304.0
    2           413.0(2 row(s) affected)
    */
      

  3.   

    declare @tab table(id int,price decimal(9,2))
    insert @tab values(1,303.7)
    insert @tab values(1,303.5)
    insert @tab values(2,413.2)
    select * from @tabselect id,convert(int,price) from @tab
    update price=convert(int,price) from @tab
      

  4.   

    select cast ('303.3' as numeric)
      

  5.   

    直接这样
    select  id , cast(price as numeric)  from table
      

  6.   


    SELECT CAST(price + 0.5 AS int(4))
    FROM tb
      

  7.   

    直接用Round()就可以四舍五入了