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
Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
vbnetcoder

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Russ Suter

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chris Luttrell

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.
vbnetcoder

ASKER
ty
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy