Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounding all Numbers in Database table

Tags:

sql

rounding

I need to round all the numbers in a column of a table to 2 decimal places (ie i need 2.109999 to become 2.11)

What is the best way to achieve this? (It only needs to be done as a one off operation)

I am using sql server 2008 R2

like image 641
coolblue2000 Avatar asked Jul 17 '26 22:07

coolblue2000


1 Answers

UPDATE table SET column = ROUND(column, 2)

If you need to modify numbers permanently. Otherwise:

SELECT ROUND(column, 2) FROM table

To keep existing values in place.

like image 191
Emyl Avatar answered Jul 20 '26 13:07

Emyl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!