rounding and updating a column

  • Hello everybody,

    I need to update a column in a small database running on SQL Server 2005 express and need some advice on how to go about it. The scenario is this:

    The table is called 'parts' and the column is 'capacity'. The capacity column needs to have every value rounded updated to the next higher number divisible by 50. I have been looking into the round and ceiling functions but am not getting anywhere. Can somebody help?

    Thank you in advance!

    Jeff

  • something like this?

    create table temp#( capacity float)

    insert into temp#

    values(13.7),

    (74.3),

    (189.7)

    update temp#

    set capacity = (cast((ROUND(capacity,0)/50)as int)+1)*50

    select * from temp#

    drop table temp#

  • Thank you, that worked out perfectly. I appreciate your help!

    Jeff

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply