Link to home
Create AccountLog in
Avatar of vbnetcoder
vbnetcoder

asked on

rounding extra zeros

When i round a number in T-SQL i get extra zeros

For example this:


SELECT Round(1.7656543543543, 2)

Returns this

1.7700000000000

How would i return just this 1.77
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Round just rounds and does not change the type of the variable.  In your case the static number 1.7656543543543 is considered NUMERIC(14,13) by SQL and thus your select returns all 13 decimals. Casting as FLOAT works of if you always need 2 decimal places then use NUMERIC(8,2) or something similar.
Avatar of vbnetcoder
vbnetcoder

ASKER

ty